cancel
Showing results for 
Search instead for 
Did you mean: 
pongo
Flight Engineer
Flight Engineer
  • 1,409 Views

rh124-9.0 ch10: SSH key removal and regenerating by restarting sshd not working

Jump to solution

Hi,

I just tried out what I saw in the course video.

Deleting ssh host keys on serverb then restarting sshd daemon, but unfortunately sshd can't start.

From course:
ssh-course.jpg

 

I tried stop/start and reboot too, with no luck.

[root@serverb student]# ls -lah /etc/ssh/*key*
-rw-r-----. 1 root ssh_keys 505 May 18 2022 /etc/ssh/ssh_host_ecdsa_key
-rw-r--r--. 1 root root 173 May 18 2022 /etc/ssh/ssh_host_ecdsa_key.pub
-rw-r-----. 1 root ssh_keys 399 May 18 2022 /etc/ssh/ssh_host_ed25519_key
-rw-r--r--. 1 root root 93 May 18 2022 /etc/ssh/ssh_host_ed25519_key.pub
-rw-r-----. 1 root ssh_keys 2.6K May 18 2022 /etc/ssh/ssh_host_rsa_key
-rw-r--r--. 1 root root 565 May 18 2022 /etc/ssh/ssh_host_rsa_key.pub
[root@serverb student]# rm -rf /etc/ssh/*key*

[root@serverb student]# ls -lah /etc/ssh/*key*
ls: cannot access '/etc/ssh/*key*': No such file or directory
[root@serverb student]# systemctl restart sshd
Job for sshd.service failed because the control process exited with error code.
See "systemctl status sshd.service" and "journalctl -xeu sshd.service" for details.
[root@serverb student]# ls -lah /etc/ssh/*key*
ls: cannot access '/etc/ssh/*key*': No such file or directory
[root@serverb student]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2024-05-27 10:54:05 EDT; 23s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 1466 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=1/FAILURE)
Main PID: 1466 (code=exited, status=1/FAILURE)
CPU: 9ms
[root@serverb student]# 

[root@serverb student]# journalctl -xeu sshd.service
░░
░░ A start job for unit sshd.service has begun execution.
░░
░░ The job identifier is 2922.
May 27 10:54:47 serverb.lab.example.com sshd[1472]: sshd: no hostkeys available -- exiting.
May 27 10:54:47 serverb.lab.example.com systemd[1]: sshd.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ An ExecStart= process belonging to unit sshd.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
May 27 10:54:47 serverb.lab.example.com systemd[1]: sshd.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ The unit sshd.service has entered the 'failed' state with result 'exit-code'.
May 27 10:54:47 serverb.lab.example.com systemd[1]: Failed to start OpenSSH server daemon.
░░ Subject: A start job for unit sshd.service has failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ A start job for unit sshd.service has finished with a failure.
░░
░░ The job identifier is 2922 and the job result is failed.

 

After reboot I can't even access to the hosts because of this. From webui console:

ssh-issue-pic1.jpg

So, it seems instead of regenerating the SSH keys, the daemon can't even start because of the missing SSH keys.

 

Is there anything I missed? or maybe in the current version it's not expected to work in this way?

 

Thanks,
Pongo

 

1 Solution

Accepted Solutions
3 Replies
Wasim_Raja
Moderator
Moderator
  • 1,371 Views

@pongo Thank you for reaching out.

I don't see "rm -rf /etc/ssh/*key*" been run either in video or course content steps, are you referring https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch10s02 or any other version?

0 Kudos
pongo
Flight Engineer
Flight Engineer
  • 1,361 Views

Hi,

 

I'm sorry, it should be https://role.rhu.redhat.com/rol-rhu/app/courses/rh124-9.0/pages/ch10 I've just corrected the topic's title now.

In the video around: 4:46 .

 

0 Kudos
pongo
Flight Engineer
Flight Engineer
  • 1,258 Views
Join the discussion
You must log in to join this conversation.