日常积累小问题

ssh登录脚本

2021-10-22  本文已影响0人  LeslieFind

参考:https://www.cnblogs.com/caoguo/p/4865413.html

#!/usr/bin/expect -f
set TARGET [lindex $argv 0]
set USER [lindex $argv 1]
set PASSWD [lindex $argv 2]
set PORT [lindex $argv 3]
set timeout 10

spawn ssh $USER@$TARGET -p $PORT
expect {
    "*yes/no" {send "yes\r"; exp_continue}
    "*password:" {send "$PASSWD\r"}
}
interact

写完后chmod +x $脚本

上一篇 下一篇

猜你喜欢

热点阅读