Root password never works when trying to SSH

I have Fedora 43 server and need to ssh into it for automating kubernetes setup.

I tried to connect manually, I always get access denied. I thought that I was using wrong password. I updated password through grub by running the following procedure:

Rebooted Fedora and and went to the GRUB menu.

pressed e to edit it.

Located the line starting with linux and move to its end.

Added a space, then typed rw init=/bin/bash at the end of the line.

Pressed Ctrl+X to boot into emergency mode.

Typed passwd and enterd the new root password twice.

Ran touch /.autorelabel to ensure SELinux relabeling on next boot.

Type exec /sbin/init to continue booting.

After rebooting Still wben I try to ssh manually, I get rejected :slight_smile:

Access denied

Am I doing something wrong

  1. Edit the configuration: Open /etc/ssh/sshd_config (or create a drop-in file in /etc/ssh/sshd_config.d/) and ensure the following lines are present and uncommented:

    PermitRootLogin yes
    PasswordAuthentication yes
    PubkeyAuthentication yes
    
  2. Restart the service: Apply changes by restarting the SSH service:

    sudo systemctl restart sshd
    

we may have to let your firewall know about the change as well.

I recommend no root login and use SSH keys for the root user if remote root access is strictly necessary.

Two things wrong.

  1. f43 will become EOL in about a month. It is highly recommended to upgrade to either f44 or f45 before making major changes.

  2. By default fedora (in most editions) disables root logins as well as root sign in with ssh. The user must sign in as a valid user after which they can perform root functions using sudo just like they would when logged in locally.

If, instead they wish to actually sign in as root using ssh (a very risky condition) they must first give the root user a password (which you have done), then alter the sshd configuration to allow root to sign in.

See man sshd_config for details

If you do set it to allow root login I strongly suggest that you enable the key feature instead of password.

Yes Rick, in my /etc/ssh/sshd_config PermitRootLogin and PasswordAuthentication yes. Firewall is disabled

As I said I have an automation script to setup Kubernetes and needs a root login without password by doing the following

ssh-keygen -t ed25519 -C “${USER}@mymachine.network.net”

then copy it through

ssh-copy-id -i ~/.ssh/id_ed25519.pub ``${REMOTE_USER}@2ndFedora.network.net

Jeff you are correct in all your statements but this is a temporary need as I said is for the automation to install K8S cluster then I disable it

Check the SELinux label on /etc/shadow. A root password reset from the GRUB emergency shell can leave that file mislabeled when the system isn’t relabeled on the next boot, and the password is then likely to be rejected.

ls -Z /etc/shadow

It should show shadow_t. If it shows anything else, run sudo restorecon -v /etc/shadow and try again.

Also confirm the settings sshd is actually using. sshd keeps the first value it reads, so a file in /etc/ssh/sshd_config.d/ can override the main config.

sudo sshd -T | grep -Ei 'permitrootlogin|passwordauthentication'

If root is still refused, sudo journalctl -u sshd -n 20 shows the reason sshd gave for the last attempt.

Drafted with AI, reviewed by me.

@Christopher, here is the output

system_u:object_r:shadow_t:s0 /etc/shadow

When I did the password it started relabling and it took a lot of time

here is the output of ls -l /etc/ssh/sshd_config.d/

-rw-------. 1 root root 412 Apr 17 2026 40-redhat-crypto-policies.conf
-rw-------. 1 root root 360 Apr 17 2026 50-redhat.conf

Here is the content of the 2nd file

SyslogFacility AUTHPRIV

KbdInteractiveAuthentication no

GSSAPIAuthentication yes
GSSAPICleanupCredentials no

UsePAM yes

X11Forwarding yes

    AcceptEnv COLORTERM

PrintMotd no


Output of sudo sshd -T | grep -Ei 'permitrootlogin|passwordauthentication

permitrootlogin yes
passwordauthentication yes

lines from journalctl

Oct 28 10:47:21 puppetmaster29 sshd-session[2470079]: Failed password for root from fe80::2863:f9c4:2f06:5f94%eth0 port 29110 ssh2
Oct 28 10:47:37 puppetmaster29 sshd-session[2470079]: Connection closed by authenticating user root fe80::2863:f9c4:2f06:5f94%eth0 port 29110 [preauth]
Oct 28 10:47:37 puppetmaster29 sshd-session[2470079]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=fe80::2863:f9c4:2f06:5f>
Oct 28 10:47:43 puppetmaster29 sshd-session[2470486]: Accepted password for salam from fe80::282b:6276:8c16:cb4e%eth0 port 29149 ssh2
Oct 28 10:47:43 puppetmaster29 sshd-session[2470486]: pam_unix(sshd:session): session opened for user salam(uid=1000) by salam(uid=0)
Oct 28 10:47:43 puppetmaster29 sshd-session[2470490]: Accepted password for salam from 192.168.1.3 port 29150 ssh2
Oct 28 10:47:43 puppetmaster29 sshd-session[2470490]: pam_unix(sshd:session): session opened for user salam(uid=1000) by salam(uid=0)
Oct 28 10:59:16 puppetmaster29 sshd-session[2475050]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=fe80::2863:f9c>
Oct 28 10:59:18 puppetmaster29 sshd-session[2475050]: Failed password for root from fe80::2863:f9c4:2f06:5f94%eth0 port 29739 ssh2
Oct 28 10:59:44 puppetmaster29 sshd-session[2475050]: Failed password for root from fe80::2863:f9c4:2f06:5f94%eth0 port 29739 ssh2
Oct 28 11:00:01 puppetmaster29 sshd-session[2475050]: Failed password for root from fe80::2863:f9c4:2f06:5f94%eth0 port 29739 ssh2
Oct 28 11:00:14 puppetmaster29 sshd-session[2475050]: Failed password for root from fe80::2863:f9c4:2f06:5f94%eth0 port 29739 ssh2
Oct 28 11:00:24 puppetmaster29 sshd-session[2475050]: Failed password for root from fe80::2863:f9c4:2f06:5f94%eth0 port 29739 ssh2
Oct 28 11:01:19 puppetmaster29 sshd[860]: Timeout before authentication for connection from fe80::2863:f9c4:2f06:5f94%eth0 to fe80::4922:d842:c5d2:8842%eth0>
Oct 28 13:16:30 puppetmaster29 systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 28 13:16:30 puppetmaster29 systemd[1]: sshd.service: Deactivated successfully.
Oct 28 13:16:30 puppetmaster29 systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 28 13:16:30 puppetmaster29 systemd[1]: sshd.service: Consumed 13.398s CPU time, 30.8M memory peak.

One thing I am not able to understand why for my login it uses IPv4 for root IPv6!

Does su - on the server accept the new root password?

ssh connects to whichever address the name resolves to first, and for root that was the IPv6 link-local address. ssh -4 forces IPv4, but that won’t change whether the password is accepted.

Drafted with AI, reviewed by me.

One thought: your SSH configuration looks fine (sshd -T confirms root login and password authentication are enabled). The Failed password for root messages indicate that the password authentication failed. However, those log entries are from before your password reset, so they don’t tell us whether the new password works.

First, try this locally on the server:

su -

Enter the new root password and see if it works. If it doesn’t, try resetting it again:

sudo passwd root

But there’s another way to avoid this problem entirely. Since you can already SSH as salam, you can add your public SSH key to root’s authorized_keys using sudo. This way, your automation script can connect directly as root using the key instead of a password.