Problem's setting up SSH

As someone that is quite new to Linux i have been having quite a bit of trouble figuring out why my commands for ssh arent working i was trying to generate new ssh keys using “dpkg-reconfigure openssh-server” when I entered this in the terminal it gave me an error message saying “rescue-ssh.target is a disabled or a static unit, not starting it” do I need to somehow start up the shh service I have tried to restart the service for ssh and then I get an issue that it says there is no such service.

I am using a raspberry pi model 3b running Kali Linux.

Any help would be very much appreciated

First install it:

sudo apt install openssh-server -y

After its installed it should enable the SystemD service.

Then you can generate your keys.

IIRC its not installed by default on the RPI’s.

In addition to Dynamic Gravity’s suggestion to confirm it’s installed…

[I] have tried to restart the service for ssh and then I get an issue that it says there is no such service.

If you ever encounter a service without an obvious unit, try adding a ‘d’ to the service name. Lots of them are aliased, but not all, and it’s possible Kali’s missing it.

sudo systemctl sshd start

Just tried it, it seems to be already installed on the newest version thanks for the suggestion though.

I’m still getting an issue of the service is unknown. “Unknown operation sshd”, “Unknown operation ssh” anything else I should try.

try
“sudo service ssh stop”
“sudo service ssh start”

or just
“sudo service ssh restart”

You running as root with kali still or did you make another account?

Start is the operation, not sshd

systemctl start sshd

1 Like

My fault. Systemd’s weird.

These commands do seem to work the problem is that after using them i got no error but when i used the command from my first post to generate new ssh keys i still got this error “rescue-ssh.target is a disabled or a static unit, not starting it”.

is there any other way i can generate and access new ssh keys?

I am still running as the root user.

Yeah no problem I cant figure it out myself so i guess that what this place is for i just have to hope some one knows what the problem might be.

I’m not sure if you where referring to an earlier persons code or not i tried to run “systemctl start sshd” it ran fine gave no output but when i ran the command to generate new ssh keys i got the same error as i posted in the first post.

anything else i should try?

Not sure i’m reading this correct, but normaly ssh keys for a user are generated using ssh-keygen
Or didn’t i understand what you are trying to do?

normaly ssh keys for a user are generated using ssh-keygen

You’re correct for user keys.

The SSH daemon also has a set, which is the source of the SSH fingerprint you verify on first connection (or publish in SSHFP records). Those are located in /etc/ssh/ssh_host_*, and generated by dpkg at install time.

User keys are only exchanged at connection, and don’t require a service to be running.

1 Like

Thanks. I knew that, i just never had to generate new keys for the Server, that’s why i was confused. I’ll copy that to my Notebook though, should i ever come across that on one of our Servers.

1 Like

I Nmap attacked my raspberry pi and tho error message says openssh is down. Nmap says it’s running on port 22 thus it’s working don’t worry about the error message.

Hi. I am having the same problem and I tried to delete the ssh_host* files with “rm /etc/ssh/ssh_host*” and it seems to work. I cd to /etc/ssh and do ls -l and the files are gone. When I dkpg-reconfigure openssh-server it still outputs the same error, despite it saying that it is creating new keys. I try to ls -l again on the directory, and the date does not change. Somehow it rewrites the old keys back. What can I do to solve this?

Hi I fixed it by:

  1. Checking if you downloaded open ssh with, apt list openssh-server if its not installed yet. type: apt install openssh-server

  2. Creating a backup for the original keys.
    sudo mkdir /etc/ssh/default_keys
    sudo mv /etc/ssh/ssh_host_* /etc/ssh/default_keys/

  3. Regenerate the keys with :
    sudo dpkg-reconfigure openssh-server

  4. Service status check
    systemctl status ssh.service

1 Like