﹎斑斓的梦ぷ

愿你眼中总有光芒,活成你想要的模样.

导航

Shell – SSH自动登录

最近由于频繁操作vps,发现每次输入密码太费劲,所以写了个自动登录shell脚本。

1.创建脚本 xxx.sh

#!/usr/bin/expect
set timeout 30
spawn ssh -l root ip地址
expect "password:"
send "密码\r"

2.将脚本目录加入环境变量

export PATH=/Users/xxxxx/shell:$PATH
这样一来在命令行随时可以调用脚本远程登录。

posted on 2018-05-25 11:09  ﹎斑斓的梦ぷ  阅读(114)  评论(0编辑  收藏  举报