SCP prompts for password when using identity_file but SSH doesn't
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/
Related videos on Youtube
Victor
Updated on September 18, 2022Comments
-
Victor over 1 year
I have created a new key using
ssh-keygen -t rsa
without a passphrase. I have then transferred the key usingssh-copy-id [email protected]
and then ssh'ed to the host usingssh '[email protected]'
or scp and it admits me without prompting for a password. However, when I try to scp using the commandscp -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 almost 4 years-i flag worked in my code thank you. gist.github.com/cemtopkaya/b07529142dcd3aa0c990991a156a6baf