2021-11-08 14:58:27
This commit is contained in:
2
ssh.exp
2
ssh.exp
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/expect
|
#!/usr/bin/expect --
|
||||||
set timeout -1
|
set timeout -1
|
||||||
set send_human {.05 0.1 1 .07 1.5}
|
set send_human {.05 0.1 1 .07 1.5}
|
||||||
eval spawn ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=password -o PubkeyAuthentication=no $argv
|
eval spawn ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=password -o PubkeyAuthentication=no $argv
|
||||||
|
|||||||
42
test.sh
42
test.sh
@@ -7,19 +7,49 @@ ssh_clean ()
|
|||||||
|
|
||||||
ssh_exec ()
|
ssh_exec ()
|
||||||
{
|
{
|
||||||
login=${1-marvin}
|
|
||||||
shift
|
|
||||||
port=${1-4242}
|
port=${1-4242}
|
||||||
shift
|
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 ()
|
main ()
|
||||||
{
|
{
|
||||||
login=${1-gbaconni}
|
port=${1-4242}
|
||||||
port=${2-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_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 $@
|
main $@
|
||||||
|
|||||||
Reference in New Issue
Block a user