Skip to content

Commit 51f8a5e

Browse files
author
littlelory
committed
shell/auto_ssh:自动ssh连接脚本
1 parent 2fbaf86 commit 51f8a5e

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

shell/auto_ssh.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/local/bin/expect -f
2+
3+
# 已密码的方式,自动建立ssh连接
4+
# 使用的不是bash,而是expect,所以需要安装expect命令
5+
# 执行方式为"expect auto_ssh.sh"
6+
7+
set timeout 3
8+
set host xxx.xxx.xxx.xxx
9+
set port 6666
10+
set password xxxxxxxx
11+
12+
spawn ssh root@$ip -p $port
13+
expect {
14+
"*yes/no" { send "yes\r"; exp_continue}
15+
"*password:" { send "$password\r" }
16+
}

0 commit comments

Comments
 (0)