Re: remote login desktop shortcuts
- From: "AHinMaine" <aharrison@xxxxxxxxx>
- Date: 22 Oct 2006 13:27:38 -0700
On Oct 20, 5:48 am, "pawright23" <mr_scro...@xxxxxxxxx> wrote:
I have a small shell script I wrote to automate everything, actually.
It reads a list of hosts from a file and presents with a menu for
choosing a host to connect and creates a new screen window for it, with
an appropriate name.
Thanks a lot for the info. Is there any chance I could nab this script
off you?
Sure, just create a list of hosts, one per line, in ~/.hosts and it
will work.
You can also just type partial names and it will take the first match.
Like if you have a biglonghostname.example.com in your list, you can
just type 's biglong' and it will match it and start an ssh session to
that host.
Also, in your ~/.screenrc, add the lines:
bind w windowlist -b
bind W windowlist -m
This will give you the nice menu for choosing windows when you hit
ctrl-a w, because the regular windowlist can't show very menu names in
its list.
#!/bin/sh
#
# usage:
#
# s l = screen -list
#
# s r = screen -r
#
# s d = screen -d
#
# s d r = screen -d -r
#
# s = show hosts
#
# s <string> = new screen window to matching host
#
# "s looking" would automatically match
# lookingglass.metrocast.net
#
# s sh = create a plain new screen window
#
# s root = create a screen window as root
#
# s con = console window using /dev/cuaU0
if [ -z "$1" ] ; then
grep -n ^ ~/.hosts
printf Number:
read CHOICE
SEARCH="^$CHOICE:"
elif [ "$1" = "r" ] ; then
screen -r
elif [ "$1" = "d" ] ; then
screen -d
elif [ "$1" = "d" ] && [ "$1" = "r" ] ; then
screen -d -r
elif [ "$1" = "l" ] ; then
screen -list
elif [ "$1" = "sh" ] || [ "$1" = "tcsh" ] ; then
screen -t aharrison
elif [ "$1" = "root" ] ; then
screen -t root su
elif [ "$1" = "con" ] || [ "$1" = "console" ] ; then
screen -t console su root -c "/usr/bin/cu -l /dev/cuaU0"
else
SEARCH="$1"
fi
if [ -n "$SEARCH" ] ; then
HOST=`grep -n ^ ~/.hosts | grep $SEARCH | awk -F\: '{print $2}' |
head -1`
if [ -n "$HOST" ] ; then
#
# A couple of the hosts in my list have special
# requirements to connection...
#
if [ "$HOST" = "server42" ] || [ "$HOST" =
"server42.example.com" ] ; then
screen -t $HOST ssh -i /mnt/key/.ssh/id_rsa $HOST
elif [ "$HOST" = "server99.example.com" ] ; then
screen -t $HOST ssh -p 5000 $HOST
else
screen -t $HOST ssh $HOST
fi
else
echo Host not found
fi
fi
#
# vim: filetype=sh et sw=4 ts=4
#
.
- References:
- remote login desktop shortcuts
- From: pawright23
- Re: remote login desktop shortcuts
- From: AHinMaine
- Re: remote login desktop shortcuts
- From: pawright23
- remote login desktop shortcuts
- Prev by Date: Re: user info
- Next by Date: Re: Severe problem after running updatemanager
- Previous by thread: Re: remote login desktop shortcuts
- Next by thread: Import private key into Solaris for use by IKE.
- Index(es):
Relevant Pages
|