Skip to content

Instantly share code, notes, and snippets.

@enukane
Created March 8, 2013 05:17
Show Gist options
  • Save enukane/5114363 to your computer and use it in GitHub Desktop.
Save enukane/5114363 to your computer and use it in GitHub Desktop.
ssh用
#!/bin/sh
# The purpose of this script is to remember "once connected host"
# by short name to make later recalling easy. Once give enough info
# (e.g. IP address, username, e.t.c.), the script generates special
# script as "connect_$name".
#
# Expample:
# 1. name host as "hoge"
# $ connect hoge # you will be asked to give infos
#
# 2. later use, no more annoying questions!
# $ connect_hoge
# or
# $ connect hoge
# change BASEDIR to move base directory
BASEDIR=$HOME/bin
# use ipv4 by default
USEV4="-4"
NAME=$1
CONSCRIPT=$BASEDIR/connect_$NAME
if [ -f $CONSCRIPT ]; then
sh $CONSCRIPT
exit
fi
echo This is New Host : $HOST
echo "Enter IP Address/Host : "
read addr
echo "Enter username [$USER]: "
read user
echo "Any options? : "
read options
case $user in
"")
echo "default user ($USER)"
user=$USER
;;
esac
touch $CONSCRIPT
echo "#!/bin/sh" > $CONSCRIPT
echo "ssh $USEV4 $addr -l$user $options" >> $CONSCRIPT
chmod a+x $CONSCRIPT
ssh $USEV4 $addr -l$user $options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment