xref: /freebsd/crypto/openssh/regress/knownhosts.sh (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1#	$OpenBSD: knownhosts.sh,v 1.2 2023/02/09 09:55:33 dtucker Exp $
2#	Placed in the Public Domain.
3
4tid="known hosts"
5
6opts="-F $OBJ/ssh_proxy"
7
8trace "test initial connection"
9${SSH} $opts somehost true || fail "initial connection"
10
11trace "learn hashed known host"
12>$OBJ/known_hosts
13${SSH} -ohashknownhosts=yes -o stricthostkeychecking=no $opts somehost true \
14   || fail "learn hashed known_hosts"
15
16trace "test hashed known hosts"
17${SSH} $opts somehost true || fail "reconnect with hashed known hosts"
18
19trace "no newline at end of known_hosts"
20printf "something" >$OBJ/known_hosts
21${SSH} $opts -ostricthostkeychecking=no somehost true \
22    || fail "hostkey update, missing newline, no strict"
23${SSH} $opts -ostricthostkeychecking=yes somehost true \
24    || fail "reconnect after adding with missing newline"
25
26trace "newline at end of known_hosts"
27printf "something\n" >$OBJ/known_hosts
28${SSH} $opts -ostricthostkeychecking=no somehost true \
29    || fail "hostkey update, newline, no strict"
30${SSH} $opts -ostricthostkeychecking=yes somehost true \
31    || fail "reconnect after adding without missing newline"
32lines=`wc -l <$OBJ/known_hosts`
33if [ $lines -ne 2 ]; then
34	fail "expected 2 lines in known_hosts, found $lines"
35fi
36