add openssh tests
This commit is contained in:
parent
99153633af
commit
b6b8b48e22
3
func/core/pkg_openssh/00-install-openssh.sh
Executable file
3
func/core/pkg_openssh/00-install-openssh.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
r_log "openssh" "Install openssh"
|
||||||
|
p_installPackageNormal openssh-clients openssh-server sshpass
|
5
func/core/pkg_openssh/01-test-ssh-listen.sh
Executable file
5
func/core/pkg_openssh/01-test-ssh-listen.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
r_log "openssh" "Ensure ssh is listening"
|
||||||
|
|
||||||
|
echo "" > /dev/tcp/localhost/22
|
||||||
|
r_checkExitStatus $?
|
16
func/core/pkg_openssh/10-test-login.sh
Executable file
16
func/core/pkg_openssh/10-test-login.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
r_log "openssh" "Testing basic login (using sshpass)"
|
||||||
|
|
||||||
|
if sshd -T | grep -q "passwordauthentication yes"; then
|
||||||
|
r_log "openssh" "Creating test user"
|
||||||
|
SSHPASS="Blu30nyx!"
|
||||||
|
useradd sshpasstest
|
||||||
|
echo "${SSHPASS}" | passwd --stdin sshpasstest
|
||||||
|
r_log "openssh" "Testing login"
|
||||||
|
sshpass -e ssh sshpasstest@localhost echo 'hello'
|
||||||
|
r_checkExitStatus $?
|
||||||
|
userdel -rf sshpasstest
|
||||||
|
else
|
||||||
|
r_log "openssh" "Skipping test"
|
||||||
|
exit 0
|
||||||
|
fi
|
32
func/core/pkg_openssh/11-test-key.sh
Executable file
32
func/core/pkg_openssh/11-test-key.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
r_log "openssh" "Testing key login (using sshpass)"
|
||||||
|
|
||||||
|
case $RL_VER in
|
||||||
|
8)
|
||||||
|
KEYTYPES="rsa ecdsa ed25519"
|
||||||
|
;;
|
||||||
|
9)
|
||||||
|
KEYTYPES="rsa ecdsa ed25519"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
KEYTYPES="ed25519"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
r_log "openssh" "Creating test user"
|
||||||
|
useradd sshkeytest
|
||||||
|
echo "Blu30nyx!" | passwd --stdin sshkeytest
|
||||||
|
|
||||||
|
for KEYTYPE in $KEYTYPES; do
|
||||||
|
r_log "openssh" "Creating key: ${KEYTYPE}"
|
||||||
|
runuser -l sshkeytest -c "echo | ssh-keygen -q -t ${KEYTYPE} -b 4096 -f ~/.ssh/id_${KEYTYPE}" > /dev/null
|
||||||
|
runuser -l sshkeytest -c "cat ~/.ssh/*pub > ~/.ssh/authorized_keys && chmod 600 ~/.ssh/*keys" > /dev/null
|
||||||
|
STRINGTEST=$(mktemp -u)
|
||||||
|
echo "${STRINGTEST}" > /home/sshkeytest/test_file
|
||||||
|
r_log "openssh" "Testing key: ${KEYTYPE}"
|
||||||
|
runuser -l sshkeytest -c "ssh -i ~/.ssh/id_${KEYTYPE} localhost | grep -q ${STRINGTEST} /home/sshkeytest/test_file"
|
||||||
|
ret_val=$?
|
||||||
|
r_checkExitStatus $ret_val
|
||||||
|
done
|
||||||
|
|
||||||
|
userdel -rf sshkeytest
|
Loading…
Reference in New Issue
Block a user