timchen86 / ssh-test Goto Github PK
View Code? Open in Web Editor NEWSSH authentication test tool
SSH authentication test tool
SSH-Test by Tim Chen <[email protected]> Date: Wed May 11 02:39:31 CST 2011 ------------------------------------------------------------------------------- Tools to test for the following the SSH authentications. public key authentication host-based authentication password authentication ------------------------------------------------------------------------------- usage: ssh-test.py [-h] -a {0,1,2} -u USER -o HOST SSH authentication test. optional arguments: -h, --help show this help message and exit -a {0,1,2} the authentication type, 0: public key, 1: password, 2: host- based. -u USER the user for public key and password authentication. -o HOST the host to perform the SSH test, for host-based authenticaion, the host name must be in FQDN. default: localhost.localdomain ------------------------------------------------------------------------------- Manual test cases: public key authentication: Run ssh command to do the test Require: 1)ssh 2)add user public key to authorized_keys Steps to test: 1) run ssh command: ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=publickey \ USER@HOST /bin/sh -c exit 2) check the return code: echo $? Expected result: Test ok on return code = 0, otherwise test failed. host-based authentication: Run ssh command to do the test Require: 1)ssh 2)turn on HostbasedAuthentication in server side sshd_config 3)add host public key to ssh_known_hosts Steps to test: 1) run ssh command: ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=hostbased \ HOST /bin/sh -c exit 2) check the return code: echo $? Expected result: Test ok on return code = 0, otherwise test failed. password authentication: Use sshpass tool to do the test Require: 1)sshpass 2)ssh 3)add user password to PASSWORDFILE. Steps to test: 1) run sshpass command: sshpass -f PASSWORDFILE ssh -o StrictHostKeyChecking=no \ -o PreferredAuthentications=password USER@HOST /bin/sh -c exit 2) check the return code: echo $? Expected result: Test ok on return code = 0, otherwise test failed. ------------------------------------------------------------------------------- Authentication verified on the server side Check file /var/log/auth.log May 13 14:39:09 xxx sshd[4246]: Accepted publickey for tim from ::1 port 50973 ssh2 May 13 15:12:51 xxx sshd[4894]: Accepted password for tim from 127.0.0.1 port 36879 ssh2 May 13 15:12:54 xxx sshd[4973]: Accepted hostbased for tim from 127.0.0.1 port 42451 ssh2
try:
proc.communicate()
signal.alarm(0)
except Alarm:
print('subprocess.Popen() takes too long. Exit.')
return False
something wrong with except Alarm:
Current arguments, -u user -o host is not good.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.