Skip to content

Commit 76612a6

Browse files
committed
Improve handling of known_hosts
1 parent b7fce33 commit 76612a6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

push.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ fi
5252
if [ ! -r ssh_host_rsa_key ]; then
5353
if [ ! -r ~/.ssh/chisel_host_key ]; then
5454
ssh-keygen -t rsa -f ~/chisel_host_rsa_key -N '' -C "chisel-ssh identity for $CHISEL_APP_NAME"
55-
echo '[localhost]:$CHISEL_LOCAL_PORT' `cat ~/chisel_host_rsa_key.pub` >> ~/.ssh/known_hosts
5655
fi
5756

5857
cp ~/.ssh/chisel_host_key ssh_host_rsa_key
58+
59+
# We always check to see if the key is in known_hosts, because this is a per-port entry
60+
hostsEntry="[127.0.0.1]:$CHISEL_LOCAL_PORT `cat ~/chisel_host_rsa_key.pub`"
61+
grep -q "$hostsEntry" ~/.ssh/known_hosts || echo "$hostsEntry" >> ~/.ssh/known_hosts
5962
fi
6063

6164
if [ ! -r id_rsa.pub ]; then

0 commit comments

Comments
 (0)