0

After updating my .ssh/known_hosts file do I need to restart a service? I tried service ssh restart but it gives ssh: unrecognized service.

1
  • 3
    No you don't, that file is read each time it is used.
    – Adam
    Commented Sep 4, 2014 at 16:06

2 Answers 2

4

No, .ssh/known_hosts is just read and used by your ssh client when you try to connect to another ssh server.

The ssh server will send your client its host key.

  • If your known_hosts file doesn't have an entry for the IP or hostname that you connected to, ssh will ask you whether to add this host and its key to the file.
  • If known_hosts does have an entry for the IP or hostname, AND the host key matches, the login will proceed immediately.
  • If an entry is found for the IP or hostname that does NOT match the host key just received, the login will be refused, and it will tell you the line number in known_hosts of the offending entry. If you are confident there is a good reason for the change, you can edit known_hosts to delete that line and then retry the ssh connection.

The known_hosts file is not used by the ssh server, (which is called sshd, not ssh), so there is no need to restart any service.

0

Looks like CentOS uses OpenSSH, the following worked: service sshd restart

1
  • 3
    You did two different things. known_hosts is used by the ssh client to connect to a SSH server. Restarting the sshd service restarts the ssh server running on your local machine. Restarting the service didn't affect how that file will be read. If you're looking to authorize a user to connect to your server, read this answer.
    – Adam
    Commented Sep 4, 2014 at 16:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .