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
Access denied
Am I doing something wrong
chillzone
(Rick The OldFart And **Private Tester**)
2
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:
f43 will become EOL in about a month. It is highly recommended to upgrade to either f44 or f45 before making major changes.
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.
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.
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.
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.
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.