Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 11-25-2010, 04:22 AM   #1
Registered: Sep 2007
Posts: 261

Rep: Reputation: 16
ssh "Permission denied (publickey)"

If I try to connect to server, I get:

martin@desktop:~> ssh -v
OpenSSH_4.1p1, OpenSSL 0.9.7g 11 Apr 2005
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to [] port 22.
debug1: Connection established.
debug1: identity file /home/martin/.ssh/identity type 0
debug1: identity file /home/martin/.ssh/id_rsa type 1
debug1: identity file /home/martin/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.5p1
debug1: match: OpenSSH_3.5p1 pat OpenSSH_3.*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.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 '' is known and matches the RSA host key.
debug1: Found key in /home/martin/.ssh/known_hosts:23
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_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/martin/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/martin/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
Unfortunately, I don't manage this server. Am I correct, that sshd on supports only publickey authentication because:

debug1: Authentications that can continue: publickey
I have .ssh/id_rsa present. Any ideas, what might cause this "Permission denied (publickey)" issue?
Old 11-25-2010, 04:24 AM   #2
Senior Member
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
Have you generated the public and private ssh key pair for your system? If the server is configured to use public key authentication, you will need to take your public key and place it on the server on the configured location.
Old 11-25-2010, 06:55 AM   #3
Senior Member
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore
Posts: 1,483

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491

If you have no direct access to this server, you wil have to provide your public key to the SYSADM staff that HAS access and ask them to install it so that you can access the account. While there, they should check the ownership and permissions of the account home, ~/.ssh folder, and files in ~/.ssh. If the permissions are wrong, ssh will refuse the connections: but the error generated is very clear about WHY and we are not seeing that.

To answer that question: yes it does appear that the server is set to allow access by secure key only.
Old 10-15-2014, 03:14 AM   #4
LQ Newbie
Registered: Oct 2014
Posts: 1

Rep: Reputation: Disabled
Red face SSHD config needs to be changed

Somehow the password based authentication has been diabled on the connecting server.

Here is the deal --

Step 1 : sudo vim /etc/ssh/sshd_config

Step 2 : find PasswordAuthentication .... infront of that change 'no' to 'yes'

Step 3 : sudo service ssh restart (Restart the SSHD server)

Thats it you can now log in to this server from any machine using user passwords
Old 10-19-2014, 06:47 PM   #5
LQ Newbie
Registered: Oct 2014
Posts: 6

Rep: Reputation: 0
-Enter ssh-keygen command.
-Asks where to save the keys
-Passphrase will allow you to secure the private keys.
-Keys are generated in /root/.ssh/
-id_rsa is private key is a public key
-Copy the public key to the next server which you want to login to your current server without password. Let's say server A to server B.
- Enter command Ssh-copy-id -i .ssh/ [from server A] root @192.168.0.x[server B]
-This ssh-copy-id will take this public key location and name of public key by default

Now you will be able to login.
Old 10-20-2014, 05:56 AM   #6
Senior Member
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore
Posts: 1,483

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
well duh!

so simrika, I take it you did not read the thread before posing?
OP cannot ssh to the server, so ssh-copy-id is not going to work either.
Old 10-20-2014, 08:30 AM   #7
LQ Newbie
Registered: Oct 2014
Posts: 6

Rep: Reputation: 0
ok I think you need to have a username infront of your server's ip address. It should be ssh username@ip address.
Old 10-20-2014, 08:28 PM   #8
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Originally Posted by m4rtin View Post
If I try to connect to server, I get:

[CODE]martin@desktop:~> ssh -v
This is potentially your problem right there.

1. are you on the same subnet, in other words are you in that LAN?
2. is the UID from your workstation the same UID you are attempting to connect to on the server?
3. the standard process for using ssh is as follows:
$ ssh <remote_user>@<IP>
note the REMOTE_USER you are missing. depending on the versions of sshd and openssh being used it may or may not allows you to connect without a user, this might not be displayed as a user error as it is checking for some type of authentication to match with said user.

4. are you able to successfully ssh in without using public keys?
5. have you verified the permissions on both your system and the remote systems /home/remote_user/.ssh directory and files?

read the links in my sig for further details.


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
ssh -- Permission denied (publickey,password,keyboard-interactive). davidkline Linux - Networking 11 08-20-2014 02:19 PM
[SOLVED] ssh killing me :( Permission denied (publickey) grail Linux - Newbie 10 07-06-2010 10:47 AM
[SOLVED] SSH - Permission denied (publickey,keyboard-interactive) sarves Linux - Newbie 3 05-12-2010 12:55 AM
No longer able to log into ssh. Password right but "permission denied" Baix Linux - Software 11 11-21-2008 12:44 PM
ssh client say me Permission denied.(publickey). linderox Linux - Networking 2 02-27-2008 09:36 AM

All times are GMT -5. The time now is 09:21 AM.

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