User Tools

Site Tools


user:abrunda1:ssh2_script

SSH2 Script

ssh2

  #!/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
user/abrunda1/ssh2_script.txt · Last modified: 2010/02/18 14:04 by abrunda1