[ale] Using ~/.ssh/config Better?

David Tomaschik david at systemoverlord.com
Fri Apr 22 16:29:02 EDT 2011


On Fri, Apr 22, 2011 at 9:13 AM, JD <jdp at algoloma.com> wrote:
> At the meeting last night a few of us were talking about the use of the
> ~/.ssh/config file to make remote ssh-based connections easier.  I use
> these all the time, especially to simplify use of non-standard ports or
> different userids across different machines. With the config file,
> there's no need to specify the alternate userid or port for any of those
> tools. Here's an example stanza:
>
> # start file ==================
> host h2
>  user pete
>  hostname home-place.dyndns.org
>  port 42080
> # end file ---------------------
>
> To connect to "ssh -p 42080 pete at home-place.dyndns.org", it is just
>
> $ ssh h2
>
> That's it.
>
> That got me wondering. Besides using key-based authentication with this
> file, are there other uses or tricks that I could be using with this
> file to further simplify ssh, sftp, scp, rsync, rdiff-backup and other
> ssh-based connections?


I'm surprised nobody has mentioned ControlMaster and ControlPath, two
of my favorite ssh options:

	ControlMaster auto
	ControlPath ~/.ssh/master-%r@%h:%p

This tells SSH "open a TCP connection, authenticate, etc, for the
first connection and leave a socket in ~/.ssh that future connections
can connect to".  So long as I have one session open to a particular
user/host/port combinations, future connections require nearly 0 time
to establish.  It's great for frequent use of SCP, popping more shells
if the remote end lacks screen, etc.



-- 
David Tomaschik, RHCE, LPIC-1
System Administrator/Open Source Advocate
OpenPGP: 0x5DEA789B
http://systemoverlord.com
david at systemoverlord.com



More information about the Ale mailing list