User Tools

Site Tools


user:abrunda1:ssh2_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

user:abrunda1:ssh2_script [2010/02/18 19:03] – created abrunda1user:abrunda1:ssh2_script [2010/02/18 19:04] (current) abrunda1
Line 1: Line 1:
 +=====SSH2 Script===== 
 +ssh2 
 +<code bash> 
 +  #!/bin/bash 
 +  ipaddress=$1 
 +  if [ -z "$ipaddress" -a -z ""
 +  then 
 +    echo "Missing 1st parameter after ssh2" 
 +    echo "The correct syntax is \"ssh2 \"0.0.0.0\"\"" 
 +  fi 
 +  if [ -n "$ipaddress" -a -z ""
 +  then 
 +    echo -n "Username to login as: (Default: root): " 
 +    read username 
 +    if [ -z "$username" -a -z  ""
 +    then 
 +        username="root" 
 +        echo -n "Specify Port Number: (Default: 22): " 
 +        read portnum 
 +        if [ -z "$portnum" -a -z ""
 +        then 
 +            portnum="22" 
 +            ssh root@$ipaddress -p $portnum 
 +        fi 
 +        if [ -n "$portnum" -a -z ""
 +        then 
 +            ssh root@$ipaddress -p $portnum 
 +        fi 
 +    fi 
 +    if [ -n "$username" -a -z ""
 +    then 
 +        echo -n "Specify Port Number: (Default: 22): " 
 +        read portnum 
 +        if [ -z "$portnum" -a -z ""
 +        then 
 +            portnum="22" 
 +            ssh $username@$ipaddress -p $portnum 
 +        fi 
 +        if [ -n "$portnum" -a -z ""
 +        then 
 +            ssh $username@$ipaddress -p $portnum 
 +        fi 
 +    fi 
 +  fi 
 +</code>