LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-26-2015, 06:51 AM   #1
Revenge7
Member
 
Registered: Mar 2015
Posts: 38

Rep: Reputation: Disabled
Unhappy RSA Key Auth. for connecting to root is not working.


Hey Guys!

Using RHEL v5.7, I am trying to make a connection between two servers with rsa key auth. I need to connect directly to the root as it's privileges are needed for changing password. RSA key is working for normal users but I cannot connect to root. I changed the sshd_config file as

PermitRootLogin without-password
RSAAuthentication yes
PubkeyAuthentication yes

and restart it (on both sides). Files permissions are below:

(Sender server=> /root/.ssh directory's permission is 700)

-rw------- 1 root root 1675 May 25 15:14 id_rsa
-rw-r--r-- 1 root root 392 May 25 15:14 id_rsa.pub
-rw------- 1 root root 2743 May 21 09:13 known_hosts
-rw-r--r-- 1 root root 1177 Mar 30 09:38 known_hosts.old

(Remote server to connect)

-rw------- 1 root root 392 Apr 20 15:35 authorized_keys
-rw------- 1 root root 668 Mar 30 10:08 id_dsa
-rw-r--r-- 1 root root 601 Mar 30 10:08 id_dsa.pub
-rw------- 1 root root 1675 Apr 28 11:09 id_rsa
-rw-r--r-- 1 root root 393 Apr 14 14:40 id_rsa.pub
-rw-r--r-- 1 root root 1178 Apr 28 08:58 known_hosts

Also I provide the verbose output when I run the ssh connection:

Username: user_of_remote_server
New Password: OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to remote_IP [remote_IP] port 44.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug3: Not a RSA1 key file /root/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 118/256
debug2: bits set: 512/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /root/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host 'remote_IP' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug2: bits set: 498/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /root/.ssh/id_rsa (0x2b9f25eb6cf0)
debug2: key: /root/.ssh/identity ((nil))
debug2: key: /root/.ssh/id_dsa ((nil))
debug3: input_userauth_banner

debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /root/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/identity
debug3: no such identity: /root/.ssh/identity
debug1: Trying private key: /root/.ssh/id_dsa
debug3: no such identity: /root/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
root@remote_IP's password:
debug3: packet_send2: adding 64 (len 60 padlen 4 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
Permission denied, please try again.
root@remote_IP's password:

Where is the problem ? I do not want to be asked password for root during rsa connection. That's why I am using without-password mode for PermitRootLogin. Thanks for your helps!

Last edited by Revenge7; 05-26-2015 at 06:54 AM.
 
Old 05-27-2015, 12:03 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

it seems to be offering up your id_rsa but is failing to authenticate. If you check the sshd log it will probably tell you exactly why. Have a look in /var/log/auth.log.

Evo2.
 
Old 05-27-2015, 01:49 AM   #3
Revenge7
Member
 
Registered: Mar 2015
Posts: 38

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by evo2 View Post
Hi,

it seems to be offering up your id_rsa but is failing to authenticate. If you check the sshd log it will probably tell you exactly why. Have a look in /var/log/auth.log.

Evo2.
There is no such file at that directory. Where can I find it from (another location) ? I saw that system log AUTH preference is commented at sshd_config, I enabled it but still there is no log file for auth.
 
Old 05-27-2015, 01:50 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

sorry, that is for Debian, on RHEL it should be /var/log/secure

Evo2.
 
Old 05-27-2015, 08:40 AM   #5
Revenge7
Member
 
Registered: Mar 2015
Posts: 38

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by evo2 View Post
Hi,

sorry, that is for Debian, on RHEL it should be /var/log/secure

Evo2.
Thanks, it gave the log. But I could not deduce anything from log.

server1 sshd[58645]: pam_unix(sshd:session): session opened for user user1 by (uid=0)
server1 su: pam_unix(su-l:session): session opened for user root by user1(uid=1004)
server1 sshd[58709]: pam_unix(sshd:session): session opened for user user1 by (uid=0)
server1 sshd[58709]: pam_unix(sshd:session): session closed for user user1

server2 sshd[36710]: pam_unix(sshd:session): session opened for user user2 by (uid=0)
server2 su: pam_unix(su-l:session): session opened for user root by user2(uid=1002)
server2 sshd[36783]: pam_unix(sshd:session): session opened for user user2 by (uid=0)
server2 sshd[36783]: pam_unix(sshd:session): session closed for user user2

server1 and user 1 are senders and others are recipients.
Is it rational ?

Last edited by Revenge7; 05-27-2015 at 08:42 AM.
 
Old 05-27-2015, 08:01 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

are there no entires where you try to ssh in as root?

Anyway you can try runnning sshd in debug mode to get more information. Get a terminal on one machine and start up an additional sshd in debug mode on a difference port. Eg on server2 as root
Code:
/usr/sbin/sshd -debug -p 9999
In another terminal on server1 try to ssh to that port on server2. Eg
Code:
ssh -p 9999 root@server2
Look in the first terminal to see what is happening with the authentication.

Evo2.

Last edited by evo2; 05-27-2015 at 08:03 PM.
 
Old 06-01-2015, 02:44 AM   #7
Revenge7
Member
 
Registered: Mar 2015
Posts: 38

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by evo2 View Post
Hi,

are there no entires where you try to ssh in as root?

Anyway you can try runnning sshd in debug mode to get more information. Get a terminal on one machine and start up an additional sshd in debug mode on a difference port. Eg on server2 as root
Code:
/usr/sbin/sshd -debug -p 9999
In another terminal on server1 try to ssh to that port on server2. Eg
Code:
ssh -p 9999 root@server2
Look in the first terminal to see what is happening with the authentication.

Evo2.
Thank you for your help. I solved the rsa connection problem by changing the sshd rsa key location parameters of the two servers as they will be same. But now I am getting

passwd: Authentication token manipulation error

when I'm trying to change the password of the remote server. Do you have any idea about this problem ? I tried

mount -o remount,rw /

and cp shadow- shadow

solutions stated on forum, but it did not work.

Last edited by Revenge7; 06-01-2015 at 02:46 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] OpenSSH: require both, Password and RSA-Key for root-login didi86 Linux - Security 8 05-14-2014 05:24 AM
RSA SecurID: RSA Web Agent, integration of RSA auth page Linux_Kidd General 1 08-28-2013 05:59 PM
SSH to root@box fails when trying key auth joseph85750 Linux - Security 2 06-19-2012 12:29 PM
Putty/SSH login failed when using RSA public key: 'Server refused our key' itsecx@gmail.com Linux - Server 10 10-04-2010 01:19 PM
ssh public key auth without root acces possible ? mrbiomathe Linux - Newbie 2 11-29-2009 02:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration