diff --git a/tests/p_openssh/_helper_sshd_user_login-with-key.expect b/tests/p_openssh/_helper_sshd_user_login-with-key.expect new file mode 100644 index 0000000..7e01d18 --- /dev/null +++ b/tests/p_openssh/_helper_sshd_user_login-with-key.expect @@ -0,0 +1,7 @@ +#!/usr/bin/expect -f +# Author: Athmane Madjoudj + +set timeout 2 +spawn ssh -o StrictHostKeyChecking=no sshtest@localhost /bin/cat ssh_test_file +send -- "\r" +expect eof diff --git a/tests/p_openssh/sshd_user_login-with-key.sh b/tests/p_openssh/sshd_user_login-with-key.sh new file mode 100644 index 0000000..0ea04b1 --- /dev/null +++ b/tests/p_openssh/sshd_user_login-with-key.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +for KeyType in rsa dsa; do + userdel -rf sshtest; useradd sshtest && echo sshtest | passwd --stdin sshtest + runuser -l sshtest -c "echo | ssh-keygen -q -t ${KeyType} -b 1024 -f ~/.ssh/id_${KeyType}" > /dev/null + runuser -l sshtest -c "cat ~/.ssh/*pub > ~/.ssh/authorized_keys && chmod 600 ~/.ssh/*keys" > /dev/null + cp ./tests/p_openssh/_helper_sshd_user_login-with-key.expect /home/sshtest/ && chmod +x /home/sshtest/*.expect + + # Create a test file + TestString=$( mktemp -u ) + echo $TestString > /home/sshtest/ssh_test_file + + t_Log "Running $0 - SSH User can login using ${KeyType} key." + runuser -l sshtest -c "~/_helper_sshd_user_login-with-key.expect" | grep ${TestString} > /dev/null 2>&1 + t_CheckExitStatus $? + userdel -rf sshtest +done \ No newline at end of file