no password ssh auth in new amazon instances
I have a script that interact with an external host with rsync/ssh.
SSH prompts me to confirm the authenticity of the host like this:
The authenticity of host 'xxxxxxxxxxxxxxxxxx' can't be established.
RSA key fingerprint is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Are you sure you want to continue co开发者_StackOverflow中文版nnecting (yes/no)?
Since every EC2 instance is a new host, I have to confirm this every time, but I want an automatic script without any user input. What is the best solution?
I know I can add -O StrictHostKeyChecking=no , but that would make external host insecure.
EDIT ! : is it possible to use my PEM file to authenticate in other servers ? I mean, mayb installing something in the external server and connect in the same way I do with instances and the PEM file
Thank you
You could try to use expect:
Expect is a Unix automation and testing tool, written by Don Libes as an extension to the Tcl scripting language, for interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, ssh, and others. It uses Unix pseudo terminals to wrap up subprocesses transparently, allowing the automation of arbitrary applications that are accessed over a terminal.
Although you might have some challenge to make it work in those cases where you connect to the same IP for a non-first time and ssh will not ask.
I think this article verify-ssh-keys-on-ec2-instances might have the information you need, or at least a starting point to scripting something.
精彩评论