0

I created keys so I can transfer files and run commands without having to enter in a password. I used this guide to do it:

http://says-story.blogspot.nl/2008/01/using-ssh-scp-sftp-without-password.html

changed the chmod to 600 on the id_dsa.pub key on the local env.

when I run this command now

scp -i /home/.ssh/id_dsa.pub /prod/tool/CODELIBRARY.txt user@remoteenv:/toload

it keeps asking for a passphrase. When I hit enter, it then asks for a password then.

but when I run this command it works without a password or passphrase:

ssh -v -l username remoteenv
5
  • 2
    *.pub are public keys, leave them at 0644. On the other hand, you need to set permissions to 0600 to the private keys on the client machine, and to the authorized_keys file on the server. It's also a good idea to change permission to 0711 to the .ssh directory.
    – lcd047
    Commented Jul 9, 2015 at 16:56
  • Is your id_dsa.pub location in your scp -i command correct? Shouldn't it be /home/user/.ssh/id_dsa.pub? Also, could you clarify on which machine you created the ssh keys? Commented Jul 9, 2015 at 17:04
  • 1
    user is same as username ? your home is /home ? not /home/joe ?
    – Archemar
    Commented Jul 9, 2015 at 20:16
  • instead of: user@remoteenv what happens when you use: [email protected] where 1.2.3.4 is the IP of the server you are connecting to? I remember this with our server we have to use the IP rather than DNS for the auto login to work properly.
    – Leptonator
    Commented Jul 9, 2015 at 20:44
  • scp also knows the option -v to output some debug info. What do they say?
    – ott--
    Commented Jul 9, 2015 at 20:52

3 Answers 3

4
scp -i /home/.ssh/id_dsa.pub 

There are two things wrong with this command. One is that /home/.ssh is unlikely to exist. SSH keys are normally in the directory called .ssh in your home directory, and your home directory is typically something like /home/bob, so the .ssh directory is /home/bob/.ssh.

The other, more conceptual, problem, is that scp (or ssh or sftp) needs to be given the private key file, but you passed the public key file. The key is used to authenticate the client on the server. The client needs to prove who it is, and to do that, it demonstrates that it knows a secret that nobody else knows: the private key. The server knows who the client is supposed to be, it knows the public key.

scp or ssh works when you don't specify a key file because it looks for the correct file by default.

1

Question... when you ran this command:

ssh-keygen -t dsa

It would have prompted you for a keyphrase, thus:

[admin@test ~]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/admin/.ssh/id_dsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 

Did you leave the passphrase blank? Or did you type in your password there? You'll want to leave the passphrase blank in this context to avoid being asked for a passphrase each time.

0

And one more thing I just found, I had to edit the .ssh/authorized_keys file to and make hostname fully qualified. Otherwise I couldn't use the fully qualified name in the scp/ssh command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .