#!/usr/bin/expect

set ip '192.168.4.5'
set pwd '123456'
set timeout 30

spawn ssh root@$ip 
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" {send "$pwd\r"}
}
interact  # 保持在远程终端

#!/usr/bin/expect

set ip [lindex $argv 0]   # 第一个位置参数
set user [lindex $argv 1] 
set pwd [lindex $argv 1]
set timeout 30

spawn ssh $user@$ip 
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" {send "$pwd\r"}
}
interact  # 保持在远程终端
 

 

相关文章:

  • 2021-10-08
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2021-07-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2021-11-15
  • 2022-12-23
  • 2021-12-27
相关资源
相似解决方案