File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11#! /bin/sh
22
3+ remove_ssh_entry () {
4+ HOST=$1
5+ SSH_FILE=$2
6+ # Remove the entry in both .ssh dirs since ssh checks different locations based on env variables and how it is launched, e.g. on boot vs. manually
7+ for DIR in ~ root/.ssh $HOME /.ssh
8+ do
9+ if [ -f " $DIR /$SSH_FILE " ]; then
10+ sed -i " /$HOST /d" " $DIR /$SSH_FILE " 2>&1 > /dev/null
11+ fi
12+ done
13+ }
14+
315add_ssh_entry () {
416 ENTRY=$1
517 SSH_FILE=$2
@@ -53,6 +65,7 @@ remote_ctrl() {
5365 echo " \$ SSH_HOST_KEY is empty"
5466 else
5567 KNOWN_HOST=" $SSH_HOST $SSH_HOST_KEY "
68+ remove_ssh_entry " $SSH_HOST " known_hosts
5669 add_ssh_entry " $KNOWN_HOST " known_hosts
5770 fi
5871
Original file line number Diff line number Diff line change 11#! /bin/sh
22
3+ remove_ssh_entry () {
4+ HOST=$1
5+ SSH_FILE=$2
6+ # Remove the entry in both .ssh dirs since ssh checks different locations based on env variables and how it is launched, e.g. on boot vs. manually
7+ for DIR in ~ root/.ssh $HOME /.ssh
8+ do
9+ if [ -f " $DIR /$SSH_FILE " ]; then
10+ sed -i " /$HOST /d" " $DIR /$SSH_FILE " 2>&1 > /dev/null
11+ fi
12+ done
13+ }
14+
315add_ssh_entry () {
416 ENTRY=$1
517 SSH_FILE=$2
@@ -53,6 +65,7 @@ remote_ctrl() {
5365 echo " \$ SSH_HOST_KEY is empty"
5466 else
5567 KNOWN_HOST=" $SSH_HOST $SSH_HOST_KEY "
68+ remove_ssh_entry " $SSH_HOST " known_hosts
5669 add_ssh_entry " $KNOWN_HOST " known_hosts
5770 fi
5871
You can’t perform that action at this time.
0 commit comments