Blame tests/p_openssh/sshd_user_login-with-key.sh

Karanbir Singh c127b6
#!/bin/sh
Karanbir Singh c127b6
40b4c8
if [ "$CONTAINERTEST" -eq "1" ]; then
40b4c8
    t_Log "Running in container -> SKIP"
40b4c8
    exit 0
40b4c8
fi
40b4c8
Pablo Greco 41c46d
keytypes="rsa"
Pablo Greco 41c46d
if [ "$centos_ver" -lt 8 ] ; then
Pablo Greco 41c46d
keytypes="$keytypes dsa"
Pablo Greco 41c46d
fi
Pablo Greco 41c46d
Pablo Greco 41c46d
for KeyType in $keytypes; do
Karanbir Singh c127b6
	userdel -rf sshtest; useradd sshtest && echo sshtest | passwd --stdin sshtest
Karanbir Singh c127b6
	runuser -l sshtest -c "echo | ssh-keygen -q -t ${KeyType} -b 1024 -f ~/.ssh/id_${KeyType}" > /dev/null
Karanbir Singh c127b6
	runuser -l sshtest -c "cat ~/.ssh/*pub > ~/.ssh/authorized_keys && chmod 600 ~/.ssh/*keys" > /dev/null
Karanbir Singh c127b6
	cp ./tests/p_openssh/_helper_sshd_user_login-with-key.expect /home/sshtest/ && chmod +x /home/sshtest/*.expect
Karanbir Singh c127b6
Karanbir Singh c127b6
	# Create a test file
Karanbir Singh c127b6
	TestString=$( mktemp -u )
Karanbir Singh c127b6
	echo $TestString > /home/sshtest/ssh_test_file
Karanbir Singh c127b6
Karanbir Singh c127b6
	t_Log "Running $0 - SSH User can login using ${KeyType} key."
Karanbir Singh c127b6
	runuser -l sshtest -c "~/_helper_sshd_user_login-with-key.expect" | grep ${TestString}  > /dev/null 2>&1
Karanbir Singh c127b6
	t_CheckExitStatus $?
Karanbir Singh c127b6
	userdel -rf sshtest
2b3708
done