2021-11-08 14:58:27

This commit is contained in:
gbaconni
2021-11-08 14:58:27 +01:00
parent b04c7a36d7
commit b0efcdc5a3
2 changed files with 37 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/expect
#!/usr/bin/expect --
set timeout -1
set send_human {.05 0.1 1 .07 1.5}
eval spawn ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=password -o PubkeyAuthentication=no $argv

42
test.sh
View File

@@ -7,19 +7,49 @@ ssh_clean ()
ssh_exec ()
{
login=${1-marvin}
shift
port=${1-4242}
shift
ssh -p ${port} -l ${login} -o StrictHostKeyChecking=no 127.0.0.1 $@
login=${1-marvin}
shift
pass=${1-Born2beRoot}
shift
export SSHPASS="${pass}"
./ssh.exp -p ${port} ${login}@127.0.0.1 $@ 2>&1 \
| grep -v -i -e '^Warning: Permanently added' -e ' password:' -e '^spawn ssh'
}
main ()
{
login=${1-gbaconni}
port=${2-4242}
port=${1-4242}
echo -n "Username: "
read -r login
if [ "${login}" == "" ]
then
login=${USER-gbaconni}
fi
echo -n "Password: "
read -s pass
if [ "${pass}" == "" ]
then
pass="Born2beRoot"
fi
ssh_clean
ssh_exec ${login} ${port} whoami
if ssh_exec ${port} ${login} ${pass} hostname -s | grep -q "^${login}42"
then
echo "OK: hostname is ${login}42"
else
echo "KO: Unexpected hostname (should be ${login}42)"
fi
if ssh_exec ${port} ${login} ${pass} lspci | grep -q -i -E "(VirtualBox|QEMU)"
then
echo "OK: VirtualBox or UTM QEMU"
else
echo "KO: Unexpected Virtual Machine"
fi
}
main $@