diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:40:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:40:04 +0000 |
commit | 25505898530a333011f4fd5cbc841ad6b26c089c (patch) | |
tree | 333a33fdd60930bcccc3f177ed9467d535e9bac6 /regress/knownhosts-command.sh | |
parent | Initial commit. (diff) | |
download | openssh-25505898530a333011f4fd5cbc841ad6b26c089c.tar.xz openssh-25505898530a333011f4fd5cbc841ad6b26c089c.zip |
Adding upstream version 1:9.2p1.upstream/1%9.2p1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | regress/knownhosts-command.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/regress/knownhosts-command.sh b/regress/knownhosts-command.sh new file mode 100644 index 0000000..8472ec8 --- /dev/null +++ b/regress/knownhosts-command.sh @@ -0,0 +1,55 @@ +# $OpenBSD: knownhosts-command.sh,v 1.3 2021/08/30 01:15:45 djm Exp $ +# Placed in the Public Domain. + +tid="known hosts command " + +rm -f $OBJ/knownhosts_command $OBJ/ssh_proxy_khc +cp $OBJ/ssh_proxy $OBJ/ssh_proxy_orig + +( grep -vi GlobalKnownHostsFile $OBJ/ssh_proxy_orig | \ + grep -vi UserKnownHostsFile; + echo "GlobalKnownHostsFile none" ; + echo "UserKnownHostsFile none" ; + echo "KnownHostsCommand $OBJ/knownhosts_command '%t' '%K' '%u'" ; +) > $OBJ/ssh_proxy + +verbose "simple connection" +cat > $OBJ/knownhosts_command << _EOF +#!/bin/sh +cat $OBJ/known_hosts +_EOF +chmod a+x $OBJ/knownhosts_command +${SSH} -F $OBJ/ssh_proxy x true || fail "ssh connect failed" + +verbose "no keys" +cat > $OBJ/knownhosts_command << _EOF +#!/bin/sh +exit 0 +_EOF +chmod a+x $OBJ/knownhosts_command +${SSH} -F $OBJ/ssh_proxy x true && fail "ssh connect succeeded with no keys" + +verbose "bad exit status" +cat > $OBJ/knownhosts_command << _EOF +#!/bin/sh +cat $OBJ/known_hosts +exit 1 +_EOF +chmod a+x $OBJ/knownhosts_command +${SSH} -F $OBJ/ssh_proxy x true && fail "ssh connect succeeded with bad exit" + +for keytype in ${SSH_HOSTKEY_TYPES} ; do + algs=$keytype + test "x$keytype" = "xssh-dss" && continue + test "x$keytype" = "xssh-rsa" && algs=ssh-rsa,rsa-sha2-256,rsa-sha2-512 + verbose "keytype $keytype" + cat > $OBJ/knownhosts_command << _EOF +#!/bin/sh +die() { echo "\$@" 1>&2 ; exit 1; } +test "x\$1" = "x$keytype" || die "wrong keytype \$1 (expected $keytype)" +test "x\$3" = "x$LOGNAME" || die "wrong username \$3 (expected $LOGNAME)" +grep -- "\$1.*\$2" $OBJ/known_hosts +_EOF + ${SSH} -F $OBJ/ssh_proxy -oHostKeyAlgorithms=$algs x true || + fail "ssh connect failed for keytype $x" +done |