Help with SSH keys.

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Help with SSH keys.

Post by impulse() »

I want to setup a box so that I can ssh to it from a certain other box and I'm taken straight into the box without any request for a password. I have followed several different tutorials to do this using SSH keys but none seems to have any affect on the standard login process.

Hopefully somebody has been through this process before and can show me where I'm going wrong. I'll show exactly what I've done.


As root in /root directory:

ssh-keygen -t rsa
scp -p ~/.ssh/authorized_keys Box B:.ssh/


On other server:

chmod 600 /root/.ssh
chmod 700 /root/.ssh/authorised_keys


And then I run 'ssh -i <key file> <server>' and it still requests a password.

Any help appreciated.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

you're copying wrong file. You need to add your public key (usually stored in ~/.ssh/id_rsa.pub) to the ~/.ssh/authorized_keys file on the box you want to connect to.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Additionally if you're still running into problems, you might need to check your SSH deamon config for the filename it uses, some use 'authorized_keys' while others use 'authorized_keys2'. These are the two most common filenames but your system may be using something completely different.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Although i can't find it right away, i remember that i had written a little shell script that concatenates all public keys in a directory into authorized_keys2 file, and creates a symlink authorized_keys to the file...

http://www.timvw.be/wp-content/code/bash/setupssh.txt

All it expects is that you place your private key files, to connect TO other machines in ~/.ssh/private and your public key files, to connect FROM other machines in ~/.ssh/public.. (In most situations your private folder would be empty, since you're not connecting TO other machines from that host)
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

Weirdan wrote:you're copying wrong file. You need to add your public key (usually stored in ~/.ssh/id_rsa.pub) to the ~/.ssh/authorized_keys file on the box you want to connect to.
This is what I have tried, but I also tried it again just and I'm still having the problem. I have checked the SSH config file and the directory is set to authorized_keys.


I have 'Box A' which I'm connecting FROM and 'Box B' which I'm connecting TO.

On Box A I have run ssh-keygen and copied the generated files across to /root/.ssh/authorized_keys on Box B and I have then run 'ssh -i id_dsa.pub <user>@<host>' on Box A but Box B is still asking for a password when I connect to it.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

usually an sshd is pretty anal about userrights on the files.. So you might want to check on that (only the owner should have rights)
Post Reply