LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-15-2016, 09:29 AM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Rep: Reputation: 39
Key-based authentication not working


Hello I had set up key-based authentication between several nodes on our network. Two nodes would connect to a third via scp to copy files. The two nodes that run scp to get the files are Ubuntu 14.04 LTS distributions, while the the third node is running Red Hat Enterprise 4 release. The root account was used because the files in question were generated by applications on the third node by that user. This system has been working for years.

Starting this morning, the system has broken down. The root account can still connect, but it requires a user to provide the password rather than the automated key-based authentication. A check of the third node's secure log file had the following entries:

Quote:
Sep 15 09:16:22 romghcmsstore sshd[21356]: Authentication refused: bad ownership or modes for directory /root
Sep 15 09:16:22 romghcmsstore sshd[21356]: Authentication refused: bad ownership or modes for directory /root
Sep 15 09:16:24 romghcmsstore sshd[21356]: Accepted password for root from ::ffff:172.27.81.128 port 39926 ssh2
The last line was the result of a user manually entering the password for root.

I ran an interactive ssh login from one of the nodes with the -v option, and the output that was generated is the following:

Quote:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 172.27.45.220 [172.27.45.220] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.9p1
debug1: match: OpenSSH_3.9p1 pat OpenSSH_3.* compat 0x01000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 42:df:61:6a:e8:25:30:95:09:58:9c:16:74:10:3a:91
debug1: Host '172.27.45.220' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password,hostbased
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-with-mic,password,hostbased
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
I have confirmed the .ssh folder on the third node has the 700 permissions, and that all files in that directory have the 600 permissions. The list of files at that location are the following:

Quote:
-rw------- 1 root root 2240 Sep 15 08:51 authorized_keys
-rw------- 1 root root 3034 Sep 15 08:51 authorized_keys_15sep16
-rw------- 1 root root 1209 Aug 7 2013 authorized_keys2
-rw------- 1 root root 1447 Aug 7 2013 authorized_keys_20aug13
-rw------- 1 root root 604 Aug 7 2013 authorized_keys2.bak
-rw------- 1 root root 842 Aug 7 2013 authorized_keys.bak
-rw------- 1 root root 10974 Sep 15 09:02 known_hosts
I have also stopped, and restarted the ssh services on the third node, but that has not solved the problem. What other steps do I need to take in order get the key authentication working again?

Thanks.
 
Old 09-15-2016, 09:36 AM   #2
gda
Member
 
Registered: Oct 2015
Posts: 130

Rep: Reputation: 27
According to:

Quote:
Originally Posted by kaplan71
Sep 15 09:16:22 romghcmsstore sshd[21356]: Authentication refused: bad ownership or modes for directory /root
it seems the problem is wrong ownership or mode of the /root directory. Check this directory is writable only by root.
 
1 members found this post helpful.
Old 09-15-2016, 09:49 AM   #3
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hello --

Thank-you for your e-mail. The /root directory did have the wrong ownership and permissions. Once I correct them, the key authentication worked.

Thanks for the help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
One-time key-based authentication-how? jamtat Linux - Server 8 11-14-2015 09:59 PM
VSFTPD Key-Based Authentication TheGaydads Linux - Newbie 3 06-12-2014 03:13 PM
[SOLVED] SSH Public Key Based Authentication LinuxDunce Linux - Security 6 08-30-2013 09:51 PM
SSH Key based authentication failure kdheepan Linux - Newbie 2 06-08-2011 08:55 AM
Key based authentication only for root for SSH the_gripmaster Linux - Security 4 04-18-2009 06:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:52 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