非交互式SCP
我正在创建一个 bash 脚本来创建新的 EC2 实例,然后在创建实例后上传文件。但是,我正在使用 scp 上传文件,因为这是我第一次连接到实例,因此脚本会提示“您确定要继续连接吗(是/否)?”因为不知道楼主的真实性。该脚本需要以非交互方式运行。
是否可以避免提示(似乎没有明显的命令行选项)。如果没有,是否有其他方法或命令可以用来上传文件?
I'm creating a bash script to create new EC2 instances and then upload a file once the instance is created. I'm using scp to upload the file, however, since this is the first time I'm connecting to the instance the script is prompted with "Are you sure you want to continue connecting (yes/no)?" since the authenticity of the host is not known. The script needs to run non-interactively.
Is it possible to avoid the prompt (there doesn't seem to be an obvious command line option). If not is there an alternative method or command I can use to upload the file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在
~/.ssh/config
中将选项StrictHostKeyChecking
设置为 no。请参阅ssh_config(5)
这也可以从命令行完成:
scp -i id -o stricthostkeychecking=no source.txt user@host:/path/
其中 id 是私钥,相应的公钥位于服务器上的authorized_keys 文件中
You can set the option
StrictHostKeyChecking
to no in~/.ssh/config
. Seessh_config(5)
This can also be done from the command line:
scp -i id -o stricthostkeychecking=no source.txt user@host:/path/
Where id is a private key where the corresponding public key resides in the authorized_keys file on the server
尽管可能不是最终且最安全的解决方案,但您可以尝试编写 expect 脚本。
Although maybe not the definitive and safest solution, you could try writing an expect script.