From 0bcc47a8373f806fa8a36a09dc10a9ff98c43fbd Mon Sep 17 00:00:00 2001 From: Anthony Cicchetti Date: Tue, 13 Oct 2020 15:14:15 -0400 Subject: [PATCH] SSH host deletion --- zsh/funcs/ssh-del | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 zsh/funcs/ssh-del diff --git a/zsh/funcs/ssh-del b/zsh/funcs/ssh-del new file mode 100644 index 0000000..29c8245 --- /dev/null +++ b/zsh/funcs/ssh-del @@ -0,0 +1,24 @@ +function ssh-del-num { + local line_no + set -u + line_no=${1} + + sed -i.bak "${line_no}d" ~/.ssh/known_hosts + set +u +} + +function ssh-del-name { + local host_name + set -u + host_name=${1} + + sed -n "/${host_name}/p" ~/.ssh/known_hosts + printf "Delete the above? (y/n)" + read -q resp + + if [[ "y" == "${resp}" ]]; then + sed -n -i.bak "/${host_name}/d" ~/.ssh/known_hosts + fi + + set +u +}