LinuxQuestions.org
Review your favorite Linux distribution.
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 12-28-2007, 11:46 AM   #1
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Rep: Reputation: 30
ssh publickey authentication


I have followed all the stepts described here
http://sial.org/howto/openssh/publickey-auth/
up until "Ket Access Limits"
and when I try to enter the server from the client I get
this
Code:
stef@stefan:~$ ssh -o PreferredAuthentications=publickey spx2@firepower
Permission denied (publickey,password).
stef@stefan:~$
 
Old 12-28-2007, 01:11 PM   #2
fuzzyworm
Member
 
Registered: Sep 2003
Location: Stroud, UK
Distribution: Kubuntu, Debian
Posts: 149

Rep: Reputation: 15
On the server-side, log in as the user and do:

Code:
cd ~/.ssh
ls -l
Look for authorized_keys, check the spelling (i.e. US English spelling of authorized), and check that the permissions are at least 'read' for the user. Also, make sure that the contents of your public key is sitting within this file somewhere:

Code:
cat authorized_keys | grep --file=id_rsa.pub
On the client side, check the file name for your own private key. You may need to specify the name on the ssh command line, i.e.:

Code:
$ ssh -i myid_rsa.prv -o PreferredAuthentications=publickey spx2@firepower
Hope this is of some help, let me know if this doesn't work.
 
Old 12-29-2007, 06:06 AM   #3
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
I have tried what you wrote here and I still get the same error
 
Old 12-29-2007, 09:04 AM   #4
digen
Member
 
Registered: Dec 2005
Location: India
Distribution: Ubuntu Feisty Fawn
Posts: 107

Rep: Reputation: 15
Try verbose output in the ssh command and see what is going on,
Quote:
ssh -v -o PreferredAuthentications=publickey spx2@firepower
 
Old 12-29-2007, 12:40 PM   #5
bakfupai
Member
 
Registered: Apr 2006
Location: Sweden
Distribution: CentOS, RHEL, SourceMage, OpenBSD
Posts: 40

Rep: Reputation: 15
check the permissions of the key on the client. might be that one that has permissions that makes it unreadable. anyway, I'm pretty sure that if you use SSH2 (which you should!) the file on the server is named ~/.ssh/authorized_keys2
 
Old 12-30-2007, 07:31 AM   #6
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
@digen
the output of verbose ssh
Code:
OpenSSH_4.6p1 Debian-5, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to firepower [192.168.1.3] port 22221.
debug1: Connection established.
debug1: identity file /home/stef/.ssh/identity type -1
debug1: identity file /home/stef/.ssh/id_rsa type 1
debug1: identity file /home/stef/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3p2 Debian-9
debug1: match: OpenSSH_4.3p2 Debian-9 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6p1 Debian-5
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 '[firepower]:22221' is known and matches the RSA host key.
debug1: Found key in /home/stef/.ssh/known_hosts:12
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
debug1: Next authentication method: publickey
debug1: Trying private key: /home/stef/.ssh/identity
debug1: Offering public key: /home/stef/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/stef/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey,password).
 
Old 12-30-2007, 11:31 AM   #7
fuzzyworm
Member
 
Registered: Sep 2003
Location: Stroud, UK
Distribution: Kubuntu, Debian
Posts: 149

Rep: Reputation: 15
Quote:
Originally Posted by bakfupai View Post
... I'm pretty sure that if you use SSH2 (which you should!) the file on the server is named ~/.ssh/authorized_keys2
Not any more:

http://sial.org/howto/openssh/#s6
 
Old 12-30-2007, 11:36 AM   #8
fuzzyworm
Member
 
Registered: Sep 2003
Location: Stroud, UK
Distribution: Kubuntu, Debian
Posts: 149

Rep: Reputation: 15
Are you using a passworded key? Are you sure that you've got the password right? Try using a key with no password, or a simple password first, just to test the system, and then replace it once you know everything works.

Also, try tightening up the permissions of the .ssh folder:
Code:
chmod 600 -R ~/.ssh
on both machines

Last edited by fuzzyworm; 12-30-2007 at 11:38 AM.
 
Old 12-31-2007, 09:34 PM   #9
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
ok,I've put appropriate permissions,
I've tried again,and I've got some better
debug output from verbose switch output.
here are those messages:
Code:
debug1: match: OpenSSH_4.3p2 Debian-9 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3p2 Debian-9
debug1: An invalid name was supplied
Configuration file does not specify default realm

debug1: An invalid name was supplied
A parameter was malformed
Validation error

debug1: An invalid name was supplied
Configuration file does not specify default realm

debug1: An invalid name was supplied
A parameter was malformed
Validation error

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 'firepower' is known and matches the RSA host key.
debug1: Found key in /home/spx2/.ssh/known_hosts:4

Last edited by spx2; 12-31-2007 at 09:35 PM.
 
Old 01-07-2008, 08:19 PM   #10
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
I've deleted all .ssh on both machines and started all over.
suppose the machines are called A and B.
I've done this
A/.ssh/id_rsa.pub -> B/.ssh/authorized_keys
B/.ssh/id_rsa.pub -> A/.ssh/authorized_keys
Now I can do ssh from A->B but not B->A.

Was the first one enough to be able to ssh both ways with public keys
or was thesecond one needed ?

Last edited by spx2; 01-11-2008 at 05:26 AM. Reason: mispelling
 
Old 01-10-2008, 05:55 PM   #11
fuzzyworm
Member
 
Registered: Sep 2003
Location: Stroud, UK
Distribution: Kubuntu, Debian
Posts: 149

Rep: Reputation: 15
In order to ssh from A to B, B needs to have the contents of A's 'id_rsa.pub' file in its authorized_keys file.

Similarly, in order to ssh from B to A, A needs the contents of B's 'id_rsa.pub' file in its authorized_keys file.

So, if you want to go both ways, then yes, you do need to do both.

Is it working now then?
 
Old 01-11-2008, 05:27 AM   #12
spx2
Member
 
Registered: Dec 2005
Distribution: debian
Posts: 160

Original Poster
Rep: Reputation: 30
I can do A->B but not B->A.
I have checked error logs and -v -o output of ssh but I can't identify the problem
 
  


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
ssh -- Permission denied (publickey,password,keyboard-interactive). davidkline Linux - Networking 11 08-20-2014 02:19 PM
connect to copssh server on winxp domain user from linux use publickey authentication imnoob Linux - General 0 12-06-2007 01:19 AM
RSA Key Authentication with SSH fail with no reply for publickey powah Linux - Security 2 11-18-2006 12:24 PM
Trouble configuring SSH publickey pioniere Linux - Security 4 02-25-2005 02:20 PM
Publickey authentication problem with OpenSSH Tularis Linux - Networking 2 03-17-2004 11:50 AM

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

All times are GMT -5. The time now is 04:39 PM.

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