Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does ssh-keygen -t rsa work if only set for root user

i.e, if the username on local system is sodium and i generate the key using the above said command and on the remote system if i place the key in /root/.ssh authorized_keys ,this works.

But on the remote system if the key is placed in /home/natrium/.ssh authorized_keys

This still prompts for a password.Is this the expected behavior or is that some thing wrong in the above procedure


share|improve this question

Check permissions on the remote system:

$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys

There is a tool that could be installed in your dist (ubuntu/debian has it) called: ssh-copy-id which will do this for you:

$ ssh-copy-id <remote>

If that doesn't work try ssh with option "-v" to see more verbose messages.

Long version:

#From client to server
client$ scp ~/.ssh/

# next, setup the public key on server
server$ mkdir ~/.ssh
server$ chmod 700 ~/.ssh
server$ cat ~/ >> ~/.ssh/authorized_keys
server$ chmod 600 ~/.ssh/authorized_keys
server$ rm ~/
share|improve this answer
Thanks will try this.. – Hulk May 31 '10 at 11:44

Check permissions from ~sodium/.ssh/authorized_keys all the way to /. If any of these are world writable ssh keys won't be trusted.

Run ssh-keygen as the user for whom you need the key. It should be run on the system to which you will be connecting.

ssh-copy-id will copy ids from the target machine to the machine on which you wish to use the key.

share|improve this answer

Try this:

ssh -v

May be you are trying to login to remote4 system as sodium, but you installed key for natrium.

share|improve this answer

Where you generate the keys doesn't matter, where you store them does.

If you want to SSH from one machine to another, then the private key needs to be in the .ssh folder in the account you are SSHing from as id_rsa, and the public key must be in the .ssh/authorized_keys file in the account you are SSHing to. The keys are for users, not for machines. So the accounts you install them into make a very big difference.

Something else to bear in mind is the version of SSH you are using, as I understand it, for SSH2 the keys should be in .ssh/authorized_keys2.

Finally, to really see what's going on, best to follow Lexsys's instructions and ssh in verbose mode with the -v flag.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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