LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   SSH Key-Gen (https://www.linuxquestions.org/questions/linux-general-1/ssh-key-gen-842134/)

wifefail 11-03-2010 11:03 AM

SSH Key-Gen
 
Hello,

I am trying to set up a SSH key between servers so no password is required when I have to "scp" files between the two.

This is what I have tried so far but still requires a password:

Code:

Code:

ssh-keygen -t rsa
scp /home/<user>/.ssh/id_rsa <server2.com>:/home/<user>/.ssh/authorized_keys

When I scp after this I wasn't expecting to need a password but it is still prompting. Now I have used this same method before and it has worked great. The only difference this time is server2 is not in the same cage.

I should also say that I have checked the authorized_keys file on the destination server to make sure the rsa key is in there and it is.

Is there something I might be doing wrong or missing?

Thanks

module0000 11-03-2010 11:11 AM

To setup password-less login, do:

1) ssh-keygen
(accept all defaults, do not set a password on the key)

2) ssh-copy-id username@destination.server
(this will prompt you for a password for 'username')

That's it, once ssh-copy-id completes, your key is stored on the remote server. You can scp/ssh to the server in the future without a password, as long as you are doing so as the user that copied the key over.

wifefail 11-03-2010 12:36 PM

Thank you for the response but I have already done that and am questioning if there would be something preventing this from working. The key is in the authorized_keys file and the user is the same.

I tried turning on debugging for scp and it is trying to pass the key but it looks like it is being rejected almost. But the keys match up on each server.

module0000 11-03-2010 12:38 PM

Check your /etc/ssh/sshd_config file for the following lines:

Code:

PubkeyAuthentication yes
AuthorizedKeysFile    .ssh/authorized_keys

(remember to restart sshd if you edit that file)

If you still have trouble, you can run `sshd` manually on another port with debugging enabled. Then you will see step-by-step the authentication process and hopefully a meaning error message.

wifefail 11-03-2010 01:00 PM

I checked the file you mentioned and it is set correctly.

The thing that is making this difficult is the source server is not really one that I have luxury of debugging services with. It is a live server and a very vital one at that (phone server). Any other ideas that might lead to a "simple" fix?

Appreciate the help.

trey85stang 11-03-2010 04:17 PM

Quote:

Originally Posted by wifefail (Post 4148220)
Thank you for the response but I have already done that and am questioning if there would be something preventing this from working. The key is in the authorized_keys file and the user is the same.

I tried turning on debugging for scp and it is trying to pass the key but it looks like it is being rejected almost. But the keys match up on each server.

If you only did what is listed in your original post, you did not do that.

what you did was copy your local private key, as the authorized_key file on the remote server. That's not going to work.

You need to dump your public key `cat id_rsa.pub` into authorized_keys txt file on the remote server.

wifefail 11-04-2010 07:33 AM

I should mention I did copy the pub key not the private key like you mentioned.

The only abnormal thing I have found is that I can only reach the the origin server via local IP. When I try to reach it through it's external IP I can not SSH into it would this have an effect on this?

trey85stang 11-05-2010 02:04 PM

Quote:

Originally Posted by wifefail (Post 4148990)
I should mention I did copy the pub key not the private key like you mentioned.

The only abnormal thing I have found is that I can only reach the the origin server via local IP. When I try to reach it through it's external IP I can not SSH into it would this have an effect on this?

check your firewalls if you can not ssh in from a remote ip address. Are you getting connection refused? or some other kind of message?


All times are GMT -5. The time now is 01:27 PM.