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
.
2 Answers
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.
Looks like CentOS uses OpenSSH, the following worked: service sshd restart
-
3You 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.– AdamCommented Sep 4, 2014 at 16:08