blob: a2b3ac3d957c3f9ea9367e3a6630276398068eb2 [file] [log] [blame]
#! /usr/bin/expect -f
#*********************************************************************
# Copyright (c) International Business Machines Corp., 2000
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# FILE : ssh
#
# PURPOSE: Tests to see that ssh rejects an invalid password
#
# SETUP: The program `/usr/bin/expect' MUST be installed.
# The PASSWD and RHOST variables MUST be set prior to execution.
#
# HISTORY:
# 03/03 Jerone Young (jeroney@us.ibm.com)
#
#
set RHOST $env(RHOST)
set TEST_USER $env(TEST_USER)
set TEST_USER_PASSWD $env(TEST_USER_PASSWD)
set timeout 90
#test invalid password
send_user "SSH Test Invalid Password \n"
set RUSER $TEST_USER
set PASSWD "invalid_password!"
spawn ssh -l $RUSER $RHOST whoami
while 1 {
sleep 2
expect {
"Are you sure you want to continue connecting (yes/no)?" { exp_send "yes\r"}
"assword:" {exp_send "$PASSWD\r"}
"Permission denied" {
send_user "SSH would not allow $RUSER to login with invalid password, Test Passed \n"
send_user "\nTEST_PASSED\n"
break
}
"$RUSER" {send_user "SSH allowed $RUSER to login with invalid pass, Test Failed \n" ;exit 1}
}
sleep 1
}
exit 0