HostOnNet Blog


Remove a servers key fingerprint from known_hosts

I was creating a program that login to remove server using PHP and run some commands. The servers key fingerprint was already on my known_hosts file. To verify script still work with out the fingerprint in known_hosts, i want to try on an unknown server or remove the fingerprint from known_hosts, this is done with command

ssh-keygen -R REMOTE_SERVER_IP

Example

$ ssh-keygen -R 162.253.153.80
# Host 162.253.153.80 found: line 495
/home/boby/.ssh/known_hosts updated.
Original contents retained as /home/boby/.ssh/known_hosts.old
$ ssh root@162.253.153.80
The authenticity of host '162.253.153.80 (162.253.153.80)' can't be established.
ECDSA key fingerprint is SHA256:6sCKwFic2Absb5C3msA9FEl8zunzj5kWMDYI2bPU/SU.
Are you sure you want to continue connecting (yes/no)? ^C
$ 

Posted in Linux