LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-24-2022, 07:26 PM   #1
road hazard
Member
 
Registered: Nov 2015
Posts: 257

Rep: Reputation: Disabled
ssh permission denied public key


Trying to ssh into a remote box. I tried using ssh-copy-id to push my keys and got this:

Code:
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/roadhazard/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
test@blah.blah.blah.blah: Permission denied (publickey).
Knowing that it would fail, I tried ssh'ing into it anyway and got this:

Code:
ssh user@blah.blah.blah.blah -p blah
user@blah.blah.blah.blah: Permission denied (publickey).
I can ssh into this remote system from other Windows and Linux boxes at my house with no issue. But this single PC can't ssh into that remote system so I don't think the problem is on the remote PC but I'm baffled as to why this one PC can't get to it.

Here's the log file from the remote PC when I attempted to ssh into it:

Code:
Aug 24 20:21:22 test sshd[1586]: Connection closed by authenticating user test1 blah.blah.blah.blah port 58320 [preauth]
Aug 24 20:21:23 test sshd[1588]: Connection closed by authenticating user test1 blah.blah.blah.blah port 58332 [preauth]
Aug 24 20:21:23 test sshd[1590]: Connection closed by authenticating user test1 blah.blah.blah.blah port 58346 [preauth]
Aug 24 20:21:24 test sshd[1592]: Connection closed by authenticating user test1 blah.blah.blah.blah port 58358 [preauth]
Does that shed light on anything?
 
Old 08-24-2022, 09:54 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
Not really. Searching a bit finds many possible causes.

Is the server configured to use keys only? A bit difficult to use ssh-copy-id without being able to login without using keys or some other authentication...

Have you previously logged in via ssh with this client?
Have you previously setup keys for this client/user?
Are the permissions correct for the .ssh directory and private key?

What distribution / version and ssh version is running on the remote and client PCs?
Have you updated either system lately?

Have you tried copying the private key from another linux box for the same remote user to see if that works?

Adding -v to debug i.e. ssh -v user@blah.blah.blah.blah -p blah might provide additional clues.

Something might be wrong with the authorized_keys file on the remote.

Last edited by michaelk; 08-24-2022 at 10:19 PM.
 
Old 08-25-2022, 07:18 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
yes, something is wrong, ssh-copy-id failed, so it did not work, the copied id cannot be used (as far as I see).
 
Old 08-25-2022, 09:47 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,484

Rep: Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556
Ensure the target server allows password based authentication, it's set up to only allow key based authentication that may be why you're not getting a password prompt on both the ssh-copy-id and ssh user@
 
Old 08-25-2022, 09:49 AM   #5
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
have you tried to ssh with -v flag?
Code:
ssh -vvv <user>@<remote machine IP>
 
  


Reply

Tags
ssh login



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
[SOLVED] SSH giving server refused public-key signature despite accepting key linuxisnew2me Linux - Security 6 09-19-2022 01:48 PM
LXer: Passwordless SSH login using public key and private key LXer Syndicated Linux News 0 02-23-2020 06:42 PM
SCP - Permanently added to list of known hosts...Permission Denied (Public Key). sudhakaranR87 Ubuntu 2 10-11-2013 03:21 AM
SSH skips public key authentication for a key, but works with another key simopal6 Linux - General 1 07-06-2011 08:33 AM
Putty/SSH login failed when using RSA public key: 'Server refused our key' itsecx@gmail.com Linux - Server 10 10-04-2010 01:19 PM

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

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