This site is now 100% read-only, and retired.

XML logo

a couple of tricks with the secure shell
Posted by prhlava on Tue 29 Aug 2006 at 15:53
Tags: none.

beginner sysadmins could find a couple of tricks with the secure shell useful...

 

Comments on this Entry

Re: a couple of tricks with the secure shell
Posted by hardik (59.95.xx.xx) on Fri 1 Sep 2006 at 13:04
Hi!

One more trick for SSH.

Assuming you have set password less login [1].

e.g.

I have three server red, blue, green (host to ip mapping has ben done in /etc/hosts file). I have set password less login [1] with my LAPTOP. Make small script call "ssh-to-server" in /tmp directory

----------------------
#!/bin/sh

ssh `basename $0` $*
----------------------

Now copy above script to /sbin, make it executable

#chmod 755 /tmp/ssh-to-server
#cp /tmp/ssh-to-server /sbin/


Now make soft link of each server (red, blue, green)

#ln -s /tmp/ssh-to-server /sbin/red
#ln -s /tmp/ssh-to-server /sbin/blue
#ln -s /tmp/ssh-to-server /sbin/green

#rm /tmp/ssh-to-server

Thats's it! Just type

#red uptime
17:25:14 up 55 days, 3:57, 2 users, load average: 0.12, 0.09, 0.05

[1] http://www.biostat.jhsph.edu/bit/nopassword.html

--
Hardik Dalwadi
National Innovation Foundation(NIF)
(http://nifindia.org)
Fan of deepOfix (http://deeproot.in)

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by prhlava (158.143.xx.xx) on Fri 1 Sep 2006 at 13:23
[ View Weblogs ]
nice one, this will make it to the next version of the article (do you want your name and url to web page to be included in the article?)...

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by hardik (59.95.xx.xx) on Sat 2 Sep 2006 at 13:10
Yes please, If you can, Please include it as article.

--
Hardik Dalwadi,
SysAdmin, National Innovation Foundation.
http://nifindia.org

deepOfix Developer
http://deeproot.in

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by dkg (166.84.xx.xx) on Sun 3 Sep 2006 at 21:31
[ View Weblogs ]
i think you might want those symlink lines (ln -s ...) to use /sbin/ssh-to-server instead of /tmp/ssh-to-server

otherwise, it appears you'll end up with some broken symlinks in /sbin.

Also, i'd recommend putting this sort of thing in /usr/local/sbin and not /sbin. According to the FHS, which debian adheres to, /sbin and /usr/sbin should be managed by the OS's package manager (dpkg, for debian). /usr/local/sbin, otoh, is totally open for the sysadmin.

This avoids possible conflicts if, say, some package later wants to install something as /sbin/red.

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by hardik (59.95.xx.xx) on Mon 4 Sep 2006 at 06:45
Hi!

Good catch, It was my mistake, it must be ...

#ln -s /sbin/ssh-to-server /sbin/red

in general.And thanks for comment on /sbin, I think you i
must put those script and links in /usr/local/sbin, so
it would be perfect Debian spcecific SSH tips. Below
is revised part for that.

#cp /tmp/ssh-to-server /user/local/sbin/

Now make soft link of each server (red, blue, green)

#ln -s /usr/local/sbin/ssh-to-server /usr/local/sbin/red
#ln -s /usr/local/sbin/ssh-to-server /usr/local/sbin/blue
#ln -s /usr/local/sbin/ssh-to-server /usr/local/sbin/green

#rm /tmp/ssh-to-server

Again thanks...

So,
Can we make article for "Debian specific SSH tips" ?

--
Hardik Dalwadi,
http://nifindia.org

Fan of deepOfix
http://deeproot.in

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by randallb (68.45.xx.xx) on Tue 5 Sep 2006 at 17:30
Actually, you can do the same thing using the ssh-argv0 command (have a look at the ssh-arv0 manpage).

Basically, you create a sym link to /usr/bin/ssh-argv0 and give it the name of the host, like so:

ln -s /usr/bin/ssh-argv0 /sbin/host.name.com

Then, to SSH into host.name.com you can just run that sym link, just like with hardik's method:

host.name.com

or

host.name.com ls -l

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by hardik (59.95.xx.xx) on Wed 6 Sep 2006 at 08:03
Hi!

I think, i have reinvented the wheel, but try was not bad!

--
Hardik Dalwadi,

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by randallb (68.45.xx.xx) on Wed 6 Sep 2006 at 16:00
As mentioned above, it is usually a better idea to put these symlinks into /usr/local/bin or /usr/local/sbin. I tend to put scripts that I write for my personal use in my ~/bin, so I would probably put these symlinks in there as well.

[ Parent ]

Re: a couple of tricks with the secure shell
Posted by prhlava (158.143.xx.xx) on Mon 4 Sep 2006 at 16:38
[ View Weblogs ]

[ Parent ]