未提供用于ssh登录的密码

Maniv G

我正在尝试使用Expect&Spawn登录到远程主机。在自动执行此操作之前,一直会出现ssh [email protected]密码提示,并且在没有提供密码的情况下将其终止。这个脚本有什么问题?

#!/usr/bin/expect
set timeout 9
passwrd=PASSWORD
username=USER_NAME
host=host.example.com

/usr/bin/expect << EOF

spawn ssh $username@$host
expect "Password:"
send "$passwrd\r"
interact

格伦·杰克曼

您混淆了期望语法和外壳语法。你要:

#!/usr/bin/expect
set timeout 9
set passwrd PASSWORD
set username USER_NAME
set host host.example.com

spawn ssh $username@$host
expect "Password:"
send "$passwrd\r"
interact

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章