SCP prompts for password when using identity_file but SSH doesn't

6,279
scp -i ~/.ssh/id_rsa.pub test.wav [email protected]:/home/test/

You're using the wrong key file here. The file with the ".pub" extension is the public key file. The corresponding file without the ".pub" extension is the private key file. When you run an ssh client to connect to a remote server, you have to provide the private key file to the ssh client.

~/.ssh/id_rsa is one of the keys which ssh tries by default. If ssh is able to authenticate without having to specify an explicit key, then scp can probably do that too:

scp test.wav [email protected]:/home/test/

If you want to specify the key file, specify the file without the ".pub" extension:

scp -i ~/.ssh/id_rsa test.wav [email protected]:/home/test/
Share:
6,279

Related videos on Youtube

Victor
Author by

Victor

Updated on September 18, 2022

Comments

  • Victor
    Victor over 1 year

    I have created a new key using ssh-keygen -t rsa without a passphrase. I have then transferred the key using ssh-copy-id [email protected] and then ssh'ed to the host using ssh '[email protected]' or scp and it admits me without prompting for a password. However, when I try to scp using the command scp -i ~/.ssh/id_rsa.pub test.wav [email protected]:/home/test/ it prompts me for a password.

    It only prompts for a passphrase for the key and user when I use the -i identity_file option, and I would like to avoid this so it can be run in a script.

  • Zeba Lodhi
    Zeba Lodhi almost 4 years