【发布时间】:2020-07-13 10:07:21
【问题描述】:
我正在编写脚本来 ssh 服务器。
我有需要验证码和密码登录的服务器,我希望脚本可以每天登录服务器并在服务器上运行一些脚本(crontab)。
我只有服务器上的访问权限,我无权在服务器上设置 crontab。 所以我想在我自己的服务器上设置 crontab 和脚本来做。
(如果我不能在服务器上运行脚本,至少我想通过一行命令登录我的服务器。)
当前流量
user ~% ssh xxxx@example.com
The authenticity of host 'example.com' can't be established.
RSA key fingerprint is SHA256?[yyyyyyyyyyyyyyyyyyy].
Are you sure you want to continue connecting (yes/no/[fingerprint])? (yes)
Verification code: (input)
Password: (input)
xxxx$ ./a.sh
我在下面写命令
print "(verification code)\n(pwd)\n" | ssh -t -t xxxx@example.com
我认为这个命令会将“code,enter,password”传递给ssh并执行一行命令登录。
但是输出是
Verification code: | (cursor)
任何人都可以帮我解决这个问题(让脚本自动按回车键)??
【问题讨论】: