使用“期望”; 自动发送密码
我正在尝试将文件从远程服务器复制到本地。 这是我运行它的脚本,通过使用“expect”自动发送密码
scp user@host:/folder/myFile ./
expect "Password: "
send "myPassword"
当我运行它时,它仍然提示输入“密码”,出了什么问题?
I am trying to copy a file from my remote server to my local. Here's my script to run it, by using 'expect' to automaticlally send in password
scp user@host:/folder/myFile ./
expect "Password: "
send "myPassword"
When I run this, it still prompts for "Password", what is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个期望脚本完成了这项工作(感谢 'zedwood' )
This expect script does the job (thanks to 'zedwood' )
虽然我同意 Sam 和 nik 的观点,但你问题的答案是你没有“按 Enter”:
While I agree with Sam and nik, the answer to you questions is that you didn't "hit enter":
请不要留下这样的脚本,因为它们可能会被其他人拾取并在其他地方使用......尝试 公钥身份验证 相反,它非常容易设置。
Please do not even leave such scripts around that might be picked up by someone else and used elsewhere… Try public key authentication instead, it is are very easy to setup.
从您尝试做的事情来看,听起来您最好使用带有公钥和私钥的 ssh 。 您可以通过 google 搜索 ssh-keygen 教程来开始使用。
From what you are trying to do it sounds like you might be better off using ssh with a public and private key. You could google for ssh-keygen tutorial to get started.