Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-interactive 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?

like image 452
Richard Dorman Avatar asked Sep 07 '09 14:09

Richard Dorman


People also ask

What is Unix SCP command?

In Unix, you can use SCP (the scp command) to securely copy files and directories between remote hosts without starting an FTP session or logging into the remote systems explicitly. The scp command uses SSH to transfer data, so it requires a password or passphrase for authentication.

How do I know if SCP is enabled Linux?

Use the command which scp . It lets you know whether the command is available and it's path as well. If scp is not available, nothing is returned.


1 Answers

You can set the option StrictHostKeyChecking to no in ~/.ssh/config. See ssh_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

like image 153
Michiel Buddingh Avatar answered Sep 21 '22 14:09

Michiel Buddingh