Jason Yu
asked on
cannot ssh to other host even with the public key copied to another host's authorized_keys file
I got the following error when I tried to ssh to another host. I enabled the password authentication in sshd_config file. My final goal is to enable keyless authentication because I have a scheduled rsync command to run in my crontab .
I used ssh-keygen command to create the default rsa private and public key for root user.
Please help me go through this step by step.
[root@magentoprod-apache1 .ssh]# ssh root@magentoprod-apache2
root@magentoprod-apache2's password:
Permission denied, please try again.
root@magentoprod-apache2's password:
Permission denied, please try again.
root@magentoprod-apache2's password:
Permission denied (publickey,gssapi-keyex,gs sapi-with- mic,passwo rd).
[root@magentoprod-apache1 .ssh]#
I used ssh-keygen command to create the default rsa private and public key for root user.
Please help me go through this step by step.
[root@magentoprod-apache1 .ssh]# ssh root@magentoprod-apache2
root@magentoprod-apache2's
Permission denied, please try again.
root@magentoprod-apache2's
Permission denied, please try again.
root@magentoprod-apache2's
Permission denied (publickey,gssapi-keyex,gs
[root@magentoprod-apache1 .ssh]#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
for the first option, mine is commented out, but I checked an existing server, it was commented out too. I guess that is because we have a ldap server, we use that ldap server to authenticate all the users.
#RSAAuthentication yes
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
AuthorizedKeysCommand /usr/libexec/openssh/ssh-l dap-wrappe r
AuthorizedKeysCommandUser ec2-user
#RSAAuthentication yes
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
AuthorizedKeysCommand /usr/libexec/openssh/ssh-l
AuthorizedKeysCommandUser ec2-user
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was able to run rsync now by enable without-password option for root user on sshdc_config file.
However, when I run the rsync command like below "rsync -avr /var/www/html/media root@magentoprod-apache2:/ var/www/ht ml/media/" , the newest files are not being copied to.
any thoughts about it?
However, when I run the rsync command like below "rsync -avr /var/www/html/media root@magentoprod-apache2:/
any thoughts about it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got this issue resolved now. thank you all experts here, I appreciate your help.
Jason
Jason
ASKER
total 20K
-rw-r--r-- 1 root root 746 Jul 21 16:58 known_hosts
drwx------. 3 root root 90 Jul 21 16:40 .
-rw------- 1 root root 1.7K Jul 21 16:39 id_rsa
-rw-r--r-- 1 root root 406 Jul 21 16:39 id_rsa.pub
drwxr-xr-x 2 root root 64 Jul 21 16:38 oldkeys
dr-xr-x---. 4 root root 4.0K Jul 18 10:05 ..
-rw------- 1 root root 953 Jul 14 15:11 authorized_keys
[root@magentoprod-apache1 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA
[root@magentoprod-apache1 .ssh]#
[root@magentoprod-apache2 .ssh]# cat authorized_keys
no-port-forwarding,no-agen
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA