I am planning to copy some files to entire network of linux machines, but when I tried to use scp it asked for confirmation and I need to type "yes" and after that I have to enter the password.

Is there some way to do this without typing "yes" and providing password?


There are two interactions here.

  1. First SSH asks to confirm the server's identity. This is necessary because an adversary might impersonate the server, to tick you into logging in and providing your password or other confidential data. The first time you ever connect to a server, you need to verify the hosts's identity. After this, SSH remembers the association between the host name and the cryptographic identity.

  2. Once SSH is satisfied that it's talking to the intended server, you need to authenticate to the user account on the server by presenting some credentials. If you haven't set up anything else, you get asked for a password.

For the server identity validation, the simplest solution is to connect to the server once from that account. Verify the identity and type “yes”. This decision is recorded in ~/.ssh/known_hosts and you won't get asked again.

You may get asked about the IP address in addition to the host name. This is annoying if the server is on a dynamic IP address. Since the fact that the IP address of the server has changed is rarely interesting, it's usually harmless to disable IP address verification by putting CheckHostIP no in the configuration file ~/.ssh/config.

For user authentication, to be able to run unattended, generate a key pair without a password. On the client machine, run ssh-keygen and enter an empty passphrase. Then run ssh-copy-id the-server.example.com to copy the public key to the server (you'll need to enter your password at that point since it's the only way the server can authenticate you so far). After this, SSH will read the key file, and since the key file has no password it can use the key to authenticate without any human intervention.


Yes. indeed, just establish password-less ssh authentication first, between the two communicating machines by using the ssh-keygen and ssh-copy-id commands. You ll be good to go.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.