LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-27-2022, 08:00 AM   #1
jolintan
Member
 
Registered: Sep 2018
Posts: 43

Rep: Reputation: Disabled
ssh root login fail in ssh server


I install ssh server on ip 192.168.0.2, I login as root and i generate rsa key, i specified passphase is test123, the file is stored as id_rsa. then in ssh server, i run ssh root@192.168.0.2 and enter my passphase test123. it said failed password, permission denied.

in my etc/ssh/sshd_config. i already specify Permitrootlogin=yes. why I still can't use ssh for root?
 
Old 01-27-2022, 08:45 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
The correct syntax is
PermitRootLogin yes

Did you restart ssh server after making configuration changes.

Did you copy the public key to the server?

If you must login in as root which most will say is not a good idea (after you copy the key) use
PermitRootLogin prohibit-password
 
Old 01-27-2022, 08:54 AM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,377

Rep: Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757
You do not appear to have transferred the server public key to the client.

When you generate a key on a SSH server, you actually generate a key pair. One is a private key that remains only on the server (think of this as a lock). The other is a public key that can be supplied to any client that wishes to connect to the server.
When a client tries to connect to the server, it needs to show that it has the public key. If the client does not have a key that matches the server private key (fits the lock), the connection is denied.

PS - Permitting root logins at all is considered a security risk. Better is to allow logins only for a normal user who can then escalate to root. Where absolutely required (e.g scripted remote backup), it is best to use a key without a passphrase.
 
1 members found this post helpful.
Old 01-27-2022, 11:01 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,678
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
I concur with "allend" on all points.

Categorically speaking, always use certificates – with or without a passphrase – and do not permit "root" login.

Furthermore, strictly limit the number of users who are capable of escalating to "root." (That is to say, "members of the wheel group.") This is the "principle of least privilege." Minimize the number of users who are capable of walking into a telephone booth and flying out wearing ugly blue tights ... This maxim applies equally to Linux, MacOS, Windows, or any and every other operating system. Take full advantage of the system's ability to say "No." "Unless you must be an administrator, you aren't one."

And, never use user-names like "admin." Who's the one-and-only super-user on the machine? Why, "suzy-q" of course ... but you'd never guess that.

Last edited by sundialsvcs; 01-27-2022 at 11:05 AM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH login to server always fail upon first attempt brukuo Linux - Newbie 15 06-10-2015 09:17 PM
[SOLVED] if [[ -n "$1" ]]; then FAIL FAIL FAIL rbees Programming 7 03-25-2015 02:39 PM
slack 7.1 on 4mb laptop via loadlin root login fail mayhew Slackware - Installation 1 09-21-2011 09:32 PM
Konsole Root Login Fail after Executable Moved eightysixme Linux - Security 4 01-03-2005 10:27 PM
Graphical login fail, text login works livewire98801 Linux - General 2 10-11-2004 06:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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