File tree 2 files changed +26
-0
lines changed 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
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
+
3
15
add_ssh_entry () {
4
16
ENTRY=$1
5
17
SSH_FILE=$2
@@ -53,6 +65,7 @@ remote_ctrl() {
53
65
echo " \$ SSH_HOST_KEY is empty"
54
66
else
55
67
KNOWN_HOST=" $SSH_HOST $SSH_HOST_KEY "
68
+ remove_ssh_entry " $SSH_HOST " known_hosts
56
69
add_ssh_entry " $KNOWN_HOST " known_hosts
57
70
fi
58
71
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
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
+
3
15
add_ssh_entry () {
4
16
ENTRY=$1
5
17
SSH_FILE=$2
@@ -53,6 +65,7 @@ remote_ctrl() {
53
65
echo " \$ SSH_HOST_KEY is empty"
54
66
else
55
67
KNOWN_HOST=" $SSH_HOST $SSH_HOST_KEY "
68
+ remove_ssh_entry " $SSH_HOST " known_hosts
56
69
add_ssh_entry " $KNOWN_HOST " known_hosts
57
70
fi
58
71
You can’t perform that action at this time.
0 commit comments