For When You Can't Have The Real Thing
[ start | index | login ]
start > CentOS > 6 > ssh > Remove Host ID

Remove Host ID

Created by dave. Last edited by dave, 209 days ago. Viewed 2,483 times. #3
[diff] [history] [edit] [rdf]
labels
attachments
(2014-06-26)

Problem

Host-ID has changed and ssh is complaining about it.

Solution

Shell alias:

# edit the ~/.ssh/known_hosts file to remove the passed line number.
#  source: >>https://chainsawonatireswing.com/2012/04/06/an-easier-quicker-way-to-edit-the-known_hosts-file-when-an-ssh-server-
changes-its-host-key/
trim-ssh () {
  cp ~/.ssh/known_hosts ~/.ssh/known_hosts_$(date +%Y%m%d-%H%M%S) ;
  sed -e "$1d" ~/.ssh/known_hosts > ~/.ssh/known_hosts_new ;
  mv -f ~/.ssh/known_hosts_new ~/.ssh/known_hosts ;
  chmod 644 ~/.ssh/known_hosts
}

Usage

Remove line 12 in the ~/.ssh/known_hosts file?

> trim-ssh 12
no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt