SSH 远程登录「记住密码」
ssh命令 是 openssh 套件中的客户端连接工具,可以给予 ssh 加密协议实现安全的远程登录服务器
$ ssh root@192.168.0.102
每次登录服务器,需要重复输入密码,服务器密码通常都是一串随机字符串,记不住!!!?
Windows
用户可以使用强大的工具XShell
Mac
也有类似免费的工具,如Termius
记住密码
推荐一款开源的 autossh
工具,就为解决这个问题,使用 expect 工具完成交互,自动根据配置用户名密码登录指定服务器
安装 expect 工具
# Linux:
$ yum install expect
$ apt-get install expect
# Mac:
$ brew install expect
安装 autossh 命令
$ git clone https://github.com/FeeiCN/autossh.git
$ sudo cp autossh/autossh /usr/local/bin/
更新配置文件
$ vim ~/.autosshrc
添加服务器配置,如下格式:
server_name|192.168.1.110|root|password|port|is_bastion
远程登录
输入 autossh
并选择需要登录的服务器编号
$ autossh
############################################################
# [AUTO SSH] #
# #
# #
# [1] www.my-server.com - 192.168.192.110:root #
# #
# #
############################################################
Server Number: 1
本作品采用《CC 协议》,转载必须注明作者和本文链接
为什么不用公钥?
O(∩_∩)O哈哈~、我也实现了一个github.com/alicfeng/sshAutoLogin