3

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.

2 Answers 2

2
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/ 
1
0

Use the extensionless file, instead of the .pub one. If you wan't to use a keyfile with a passphrase, try using sshpass:

sshpass -p "" scp -i ~/.ssh/id_rsa test.wav [email protected]:/home/test/ 

Replace password with your key's passphrase.

Install sshpass from the repositories (ex. sudo apt-get install sshpass)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.