Ubuntu – restart ssh and rsa key

ssh

I installed openssh serve on my computer with Ubuntu 16.04. Then I generated rsa key using the following instructions:linux rsa. I also transfered it to host as suggested in the link, though I don't understand why I need to transfer when host is my local computer.

I tried to sudo restart ssh

but got the following error message:

    restart: Unable to connect to Upstart: 
Failed to connect to socket /com/ubuntu/upstart: Connection refused

Do you know what is wrong and how to fix it?

ssh localhost commands works fine.

Also where is private key and can I simply move it to computer that I will be logging from?

Best Answer

(Adding this as an answer from the comments)

sudo restart ssh

should be:

sudo service ssh restart

The private/public RSA SSH keys are located in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub, respectively. You can transfer the public key to another machine to connect to it through public key authentication. This can be done via ssh-copy-id like so:

ssh-copy-id username@host

Alternatively, you can append your public key (id_rsa.pub) to the server's /home/username/.ssh/authorized_keys file, which is in essence what ssh-copy-id does.