LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-13-2014, 07:08 AM   #1
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Rep: Reputation: 72
ssh public/private key not working


Hi all,

My client has setup a new server and has generated a new key pair. Now, they sent me their public key which I have to setup to the same user and server they have been connecting to.

Unfortunately, I can't get to make things work. I have already appended their public key to /home/myuser/.ssh/authorized_keys, with permission 644.

The account myuser is not locked on myserver. Also, I have asked for verbose output, and from the below, I think the connection pushed through so I am assuming there's no network issue here whatsoever.

here's the output of ssh -v

Code:
theiruser@theirserver:/theirdirectory/theiruser> ssh -v myuser@myserver.com 
OpenSSH_5.1p1, OpenSSL 0.9.8j-fips 07 Jan 2009 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: Applying options for * 
debug1: Connecting to myserver.com [10.227.58.223] port 22. 
debug1: Connection established. 
debug1: identity file /theirdirectory/theiruser/.ssh/id_rsa type 1 
debug1: identity file /theirdirectory/theiruser/.ssh/id_dsa type 2 
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.2p1+sas 
debug1: match: OpenSSH_5.2p1+sas pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_5.1 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client aes128-cbc hmac-md5 none 
debug1: kex: client->server aes128-cbc hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<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: Host 'myserver.com' is known and matches the RSA host key. 
debug1: Found key in /theirdirectory/theiruser/.ssh/known_hosts:14 
debug1: ssh_rsa_verify: signature correct 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Next authentication method: publickey 
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_rsa 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_dsa 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Next authentication method: keyboard-interactive 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Next authentication method: password 
myuser@myserver.com's password:
Any ideas please?

Thanks!
 
Old 10-13-2014, 08:24 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Look at server-side logs and check all owners and modes in the pathname of authorized_keys.

http://www.snailbook.com/faq/
 
Old 10-13-2014, 10:07 AM   #3
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Rep: Reputation: 78
I couldn't find a reference to your sshd_config and the option
Quote:
RSAAuthentication yes
PubkeyAuthentication yes
So just let me ask whether you have changed this and restated the sshd.
Note:
- if you limit the access by AllowUsers option in sshd_config you need to add the required user to the list
 
Old 10-13-2014, 06:52 PM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
check out the links in my cig, they should help you out. sounds like a permissions issue at one end of the other.
 
Old 10-13-2014, 07:14 PM   #5
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Original Poster
Rep: Reputation: 72
Thanks all for the responses. It does look like a permission issue, though I am not sure what exactly to check. From the lines below, either the private key cannot be read or it does not match the public key (though my client would disagree on this).

Code:
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Next authentication method: publickey 
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_rsa 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_dsa 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Next authentication method: keyboard-interactive 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Next authentication method: password 
myuser@myserver.com's password:
The following are in my sshd_config. The thing is, logging in to other users in myserver using ssh is working, so if something's wrong with sshd_config, I don't know what to check. Also, I am not sure if anyone has ever logged in to 'myuser' user using ssh before.

Code:
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes 
IgnoreRhosts yes
UsePrivilegeSeparation yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PasswordAuthentication no
 
Old 10-13-2014, 10:48 PM   #6
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Original Poster
Rep: Reputation: 72
Just a quick question, does the output above mean that there is no network/port/firewall issue ongoing? I assumed that since technically, ssh on both servers are already able to communicate.

Tnx
 
Old 10-13-2014, 11:41 PM   #7
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,

as pointed out by linosaurusroot, the server side logs are the best place to look to solve this quickly. Check for example /var/log/auth.log or /var/log/secure (varies with distro).

HTH,

Evo2.
 
Old 10-14-2014, 12:10 AM   #8
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
http://www.openssh.com/faq.html#3.14 if the logs mentioned by evo2 contain entries about a permissions problem.
 
1 members found this post helpful.
Old 10-14-2014, 12:37 AM   #9
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Original Poster
Rep: Reputation: 72
Thanks, I'll look at the log files. BTW, it's AIX 7.1 (if thread has to move, please do so).

For the moment, I'd like to confirm, since they were able to connect to my server and see the outputs of ssh, does this mean that there is no network/port/firewall issue ongoing? I assumed this since ssh on both servers are already able to communicate.
 
Old 10-14-2014, 01:55 AM   #10
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,
Quote:
Originally Posted by ilesterg View Post
Thanks, I'll look at the log files. BTW, it's AIX 7.1 (if thread has to move, please do so).
From the log it seems to be using openssh (as do most linux distros), so it should be ok to keep the thread here.

Quote:
For the moment, I'd like to confirm, since they were able to connect to my server and see the outputs of ssh, does this mean that there is no network/port/firewall issue ongoing? I assumed this since ssh on both servers are already able to communicate.
The ssh client output shows that it has connected to an openssh server.

Evo2.
 
Old 10-14-2014, 03:13 AM   #11
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Original Poster
Rep: Reputation: 72
That makes perfect sense. Thanks.

One more thing, the following lines confuse me since it says public key being offered. I was expecting the private key will be used for authentication, since we setup the public key in the server's authorized_keys file.

Code:
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_rsa 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_dsa
Can you please enlighten me?
 
Old 10-14-2014, 03:25 AM   #12
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,

yeah that is slightly strange output. Looking at the previous line we see:
Code:
debug1: Next authentication method: publickey 
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_rsa 
debug1: Authentications that can continue: publickey,password,keyboard-interactive 
debug1: Offering public key: /theirdirectory/theiruser/.ssh/id_dsa
I think this just means that the publickey offered by the server is being tried against the private rsa ans dsa private keys held by the client. It is consistent with what I see when using ssh with rsa authentication.

Evo2.
 
Old 10-21-2014, 06:56 AM   #13
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Original Poster
Rep: Reputation: 72
Hello,

Ok I give up. The last move is to ask them to run
Code:
ssh -vvv -oIdentityFile=/their/long/path/theirusr/.ssh/id_dsa myuser@myserver.com
..and here's what they gave me.
Code:
theirusr@theirserver:/their/long/path/theirusr> ssh -vvv -oIdentityFile=/their/long/path/theirusr/.ssh/id_dsa myuser@myserver.com 
OpenSSH_5.1p1, OpenSSL 0.9.8j-fips 07 Jan 2009 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: Applying options for * 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to myserver.com [10.225.146.170] port 22. 
debug1: Connection established. 
debug3: Not a RSA1 key file /their/long/path/theirusr/.ssh/id_dsa. 
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 
debug2: key_type_from_name: unknown key type '-----END' 
debug3: key_read: missing keytype 
debug1: identity file /their/long/path/theirusr/.ssh/id_dsa type 2 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p2+patch5 
debug1: match: OpenSSH_5.8p2+patch5 pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_5.1 
debug2: fd 3 setting O_NONBLOCK 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,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-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr 
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,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: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256 
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,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,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_setup: found hmac-md5 
debug1: kex: server->client aes128-cbc hmac-md5 none 
debug2: mac_setup: found hmac-md5 
debug1: kex: client->server aes128-cbc 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: 136/256 
debug2: bits set: 530/1024 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug3: check_host_in_hostfile: filename /their/long/path/theirusr/.ssh/known_hosts 
debug3: check_host_in_hostfile: match line 9 
debug3: check_host_in_hostfile: filename /their/long/path/theirusr/.ssh/known_hosts 
debug3: check_host_in_hostfile: match line 9 
debug1: Host 'myserver.com' is known and matches the RSA host key. 
debug1: Found key in /their/long/path/theirusr/.ssh/known_hosts:9 
debug2: bits set: 499/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: /their/long/path/theirusr/.ssh/id_dsa (0x7f057a0dabc0) 
debug1: Authentications that can continue: publickey 
debug3: start over, passed a different list publickey 
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: /their/long/path/theirusr/.ssh/id_dsa 
debug3: send_pubkey_test 
debug2: we sent a publickey packet, wait for reply 
debug1: Authentications that can continue: publickey 
debug2: we did not send a packet, disable method 
debug1: No more authentication methods to try. 
Permission denied (publickey).
 
Old 10-21-2014, 10:32 PM   #14
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,

have you looked at the server log yet?

Evo2.
 
Old 10-23-2014, 06:04 AM   #15
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Original Poster
Rep: Reputation: 72
Sad part is, the AIX server doesn't have any of these files for some reason.
/var/log/secure
/var/log/auth.log
/var/log/secure

I've read this already and learned about StrictModes in SSH; though there's no way for me to get the approval to set this to No, which is not even advisable.

So, I compare the directories of myuser to anotheruser which is a user that other vendors can connect to.
ls -al /home/myuser/ | grep .ssh
ls -l /home/myuser/.ssh/authorized_keys
ls -al /home/anotheruser/ | grep .ssh
ls -l /home/anotheruser/.ssh/authorized_keys
..and the permissions are the same.

I'll paste any updates, but feel free to give me ideas.

Thanks!
 
  


Reply

Tags
ssh



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
SSH authentication using private/public key pair is not working out ksen.dil4u Linux - Software 2 05-29-2013 12:17 PM
SSH Public/Private key pair wh33t Linux - Security 4 10-10-2012 04:09 PM
SSH with passwordless public/private key not working on another account on server infocom Linux - Server 14 12-27-2010 05:09 AM
SSH Public/Private Key Fail. Help Please! hawk__0 Linux - Networking 9 11-07-2008 03:36 PM
need help with SSH private/public key taduser Linux - Security 2 04-02-2007 07:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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