SSH Keys between RHEL 5 and Solaris 10

Hi all

Has anyone ever successfully set up ssh key pairs for "passwordless" logins between rhel and Solaris?
I've set it up many times before between Solaris systems but i'm having difficulty doing between the two OS's in question.
What I have done so far is append the contents of the rhel user's id_rsa.pub file to the authorized_keys file of the same user on the Solaris machine.

Any help will be appreciated.
Thanks

What exactly is the problem you are having? Asking the forum whether anyone has ever successfully set up ssh key pairs for "passwordless" logins between rhel and Solaris does not provide many clues to your problem.

What I meant by " having difficulty" is that I can't get it to work. I'm being prompted for a password instead of being able to log in without having to put in a password.
Apologies for the possible misunderstanding.

What's the permissions on the .ssh directory, the directory it's in and of the authorized_keys file, on both servers?

Did you (i.e.) "scp" the id_rsa.pub file, or cut and paste it?

I tried a cut and paste as well as the following command:

cat .ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys'

The permissions on the files are as follows:

drwxr-xr-x   2 user    other        512 Nov  9 14:24 .ssh
-rw-r--r--   1 user    other        396 Nov  9 14:23 authorized_keys

There's really no reason to grant more permissions than is absolutely necessary to allow SSH to work. For this reason, I always grant 700 on the .ssh directory, and 600 on the authorized_keys (it could be less, but then editing the file get's on my nerves afterwards!).

In RHEL, you should also pay attention to the parent directory of the .ssh directory. Remove write for group, if it's set.

I asked about "cut and paste", since it might have happened that the key was pasted incorrectly over two lines, instead of one, and that would obviously break it.

I tried the same thing from another Redhat machine.

ssh-keygen -t rsa
cat .ssh/id_rsa.pub | ssh user@solaris_server 'cat >> .ssh/authorized_keys'

And still no joy :confused:

I'm thinking that it can't be done between the two different OS's.
I'm open to suggestions.

It most certainly can be done!

$ hostname
rhel1

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/scott/.ssh/id_rsa):
Created directory '/home/scott/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/scott/.ssh/id_rsa.
Your public key has been saved in /home/scott/.ssh/id_rsa.pub.
The key fingerprint is:
12:02:77:22:be:6a:47:7d:aa:92:d6:8b:ac:56:07:ee scott@rhel1


$ cat .ssh/id_rsa.pub | ssh scott@sol10_1 'cat >> .ssh/authorized_keys'
The authenticity of host 'sol10_1 (sol10_1)' can't be established.
RSA key fingerprint is c5:67:11:23:ba:52:be:b7:1c:e0:d5:69:c9:b4:dc:24.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'sol10_1' (RSA) to the list of known hosts.
Password: *********
$

$ ssh scott@sol10_1
Last login: Fri Nov 11 09:52:37 2011 from rhel1
$ hostname
sol10_1

I would remove the key from the authorized_keys file on your Solaris server, and start again.

I set this up first time, with no issues whatsoever.

Thanks Scott.

I followed your method exactly but I still get prompted for a password.

Then I tried to do it with a different user and got it to work first time. :b:
The only difference that I can see that could possible cause a problem is that the user I'm not having any success with has a numerical value as the first character of the user name. eg: 5chsuser

Do you think this could be a problem?

Most likely. How did you create this user on Solaris?

root@sol10_1 (global) # useradd -u 140123 -g 10 -d /home/5cott -s $(which ksh) 5cott
UX: useradd: 5cott name first character should be alphabetic.

On the Solaris machine it gave me that message about the first character but still created the user.
I used the same user to set up ssh keys between two Solaris machines and it worked successfully. So maybe it is just a RHEL issue. I tried doing it with the same user between two Redhat machines and it also doesn't work :confused:

Ha ha. You're right. I didn't notice it had created the user anyway.

I just repeated the process with the new user 5cott and it worked fine too.

Are you sure you copied the correct key to the correct place for the correct users?

i tested from linux to Solaris and vice verse is working for me without any issue's

I'm 100% sure my man. I think what I'll do is just delete the user and recreate it.
:wall:

Good call... do it... do it now... and don't pass "Go" until you've done it, ya hear me?!

PS: Good luck :slight_smile:

 chmod 700 $HOME/.ssh

Apologies for late reply, I was away from work for a week.
I have trashed the user and recreated it on the RH box. Same result though.
@vgersh99, I have modified permissions as well.

I did it step by step as you did it, Scott. I'm going to keep playing around with this, I need to get it right.

Ok so I've picked this up again after having to attend to more urgent matters. For testing purposes I set up two VM's on my laptop. One is running RHEL 6 and the other is running Solaris 10. Both for x86 platform.
I can successfully set up key pairs between the two VM's using the methods mentioned in this thread. (Log in without password from Redhat machine to the Solaris machine).
I then tried to set up a key pair between my Redhat VM and the Solaris server I'm actually trying to get it working on and it doesn't work. So that's two different versions of Redhat that doesn't work but it works from the Redhat VM to the Solaris (latest version 10 x86) VM.
I noticed that the ssh package versions are slightly different between the two Solaris instances. I can't however get that version because the server is running on the SPARC platform and already has the latest ssh package for version 10.
If there are any more ideas out there feel free to comment. Just putting it out there :confused:

From the user who you're setting up passwordless, can you paste the output of:

ssh -vvv user@host

That'll tell us where it's going wrong.

My money's (but i've always been a rotten gambler!) on this idea:

ssh checks perms on the files under ~/.ssh, e.g. if ~/.ssh/id_rsa is anything other than chmod 400 it rubber ear's the file :slight_smile:

To give you some hope - if i had �1 for every time i've set this up for production i wouldn't need to work anymore.

There can be loads of small bumps in the road with this - things like keon with dodgy LATs running on the remote host or business groups with policy's that mean AuthorizedKeysFile location is set elsewhere than ~/.ssh/authorized_keys on the remote host. Fun fun fun! :slight_smile:

Hi craigp84

The output below:

ssh -vvv user@solarishost
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to solarishost [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /home/directory/.ssh/identity type -1
debug3: Not a RSA1 key file /home/directory/.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 /home/directory/.ssh/id_rsa type 1
debug1: identity file /home/directory/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.1.2
debug1: no match: Sun_SSH_1.1.2
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-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,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: gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,blowfish-cbc,3des-cbc
debug2: kex_parse_kexinit: aes128-cbc,blowfish-cbc,3des-cbc
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: ar-EG,en-CA,es-MX,ar,en-US,es,fr,fr-CA,i-default
debug2: kex_parse_kexinit: ar-EG,en-CA,es-MX,ar,en-US,es,fr,fr-CA,i-default
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-cbc hmac-md5 none
debug2: mac_init: 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: 120/256
debug2: bits set: 487/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/directory/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename /home/directory/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host 'solarishost' is known and matches the RSA host key.
debug1: Found key in /home/directory/.ssh/known_hosts:1
debug2: bits set: 537/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: /home/directory/.ssh/identity ((nil))
debug2: key: /home/directory/.ssh/id_rsa (0x2af48ff753a0)
debug2: key: /home/directory/.ssh/id_dsa ((nil))
debug3: input_userauth_banner

xxxxxxxxxxxxxxxxxxxxxxx

debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug3: start over, passed a different list gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug3: Trying to reverse map address xx.xx.xx.xx.
debug1: Unspecified GSS failure.  Minor code may provide more information
Unknown code krb5 195

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

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

debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/directory/.ssh/identity
debug3: no such identity: /home/directory/.ssh/identity
debug1: Offering public key: /home/directory/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug1: Trying private key: /home/directory/.ssh/id_dsa
debug3: no such identity: /home/directory/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password: