1*4d3fc8b0SEd Maste# $OpenBSD: knownhosts.sh,v 1.2 2023/02/09 09:55:33 dtucker Exp $ 21323ec57SEd Maste# Placed in the Public Domain. 31323ec57SEd Maste 41323ec57SEd Mastetid="known hosts" 51323ec57SEd Maste 61323ec57SEd Masteopts="-F $OBJ/ssh_proxy" 71323ec57SEd Maste 81323ec57SEd Mastetrace "test initial connection" 91323ec57SEd Maste${SSH} $opts somehost true || fail "initial connection" 101323ec57SEd Maste 111323ec57SEd Mastetrace "learn hashed known host" 121323ec57SEd Maste>$OBJ/known_hosts 131323ec57SEd Maste${SSH} -ohashknownhosts=yes -o stricthostkeychecking=no $opts somehost true \ 141323ec57SEd Maste || fail "learn hashed known_hosts" 151323ec57SEd Maste 161323ec57SEd Mastetrace "test hashed known hosts" 171323ec57SEd Maste${SSH} $opts somehost true || fail "reconnect with hashed known hosts" 18*4d3fc8b0SEd Maste 19*4d3fc8b0SEd Mastetrace "no newline at end of known_hosts" 20*4d3fc8b0SEd Masteprintf "something" >$OBJ/known_hosts 21*4d3fc8b0SEd Maste${SSH} $opts -ostricthostkeychecking=no somehost true \ 22*4d3fc8b0SEd Maste || fail "hostkey update, missing newline, no strict" 23*4d3fc8b0SEd Maste${SSH} $opts -ostricthostkeychecking=yes somehost true \ 24*4d3fc8b0SEd Maste || fail "reconnect after adding with missing newline" 25*4d3fc8b0SEd Maste 26*4d3fc8b0SEd Mastetrace "newline at end of known_hosts" 27*4d3fc8b0SEd Masteprintf "something\n" >$OBJ/known_hosts 28*4d3fc8b0SEd Maste${SSH} $opts -ostricthostkeychecking=no somehost true \ 29*4d3fc8b0SEd Maste || fail "hostkey update, newline, no strict" 30*4d3fc8b0SEd Maste${SSH} $opts -ostricthostkeychecking=yes somehost true \ 31*4d3fc8b0SEd Maste || fail "reconnect after adding without missing newline" 32*4d3fc8b0SEd Mastelines=`wc -l <$OBJ/known_hosts` 33*4d3fc8b0SEd Masteif [ $lines -ne 2 ]; then 34*4d3fc8b0SEd Maste fail "expected 2 lines in known_hosts, found $lines" 35*4d3fc8b0SEd Mastefi 36