| #! /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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| # |
| # FILE : ssh |
| # |
| # PURPOSE: Tests to see that ssh accepts a valid user (non-root) |
| # |
| # SETUP: The program `/usr/bin/expect' MUST be installed. |
| # |
| # 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 RUSER $TEST_USER |
| set PASSWD $TEST_USER_PASSWD |
| |
| set timeout 90 |
| |
| #test valid username |
| |
| send_user "TEST: SSH allow (non-root) valid User \n" |
| |
| 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" |
| } |
| -re "Permission denied (.*)\." { |
| send_user "\nSSH would not allow $RUSER to login, Test\ |
| FAILED \n" |
| exit 1 |
| } |
| "$RUSER" { |
| send_user "SSH allowed $RUSER to login, Test PASSED \n" |
| exit 0 |
| } |
| } |
| sleep 1 |
| } |
| |
| exit 1 |