<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>duckland.org news (ssh)</title><link>http://www.duckland.org/</link><description></description><atom:link href="http://www.duckland.org/categories/ssh.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 10 Jun 2015 05:13:30 GMT</lastBuildDate><generator>http://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Making life easy over flaky links</title><link>http://www.duckland.org/posts/200912making-life-easy-over-flaky-links.html</link><dc:creator>Don Harper</dc:creator><description>&lt;h1&gt;Making life easy over flaky links&lt;/h1&gt;

&lt;p&gt;I tend to work over VPN, which we know can be flaky at times, Since I work on server, I spend a lot of time ssh’ed into hosts. I was getting tired of the lost time having to restart what I was working on every time the VPN dropped (which could be as much as every 15 minutes on a bad day). While I already used screen to handle the lack of terminals (Alas, I am forced to use a Windows laptop to VPN in with), I thought there could be an easier way to do this.&lt;/p&gt;

&lt;p&gt;The way I tend to work is that I ssh into a jump server, fire up screen, then ssh into the hosts I need to work on, and fire up screen on those hosts.&lt;/p&gt;

&lt;p&gt;Now, this is nice, but it can get a bit tiring to do it all over
again. So, I found a tool called
&lt;a href="http://www.harding.motd.ca/autossh/"&gt;autossh&lt;/a&gt; which will automatically restart your ssh session if it drops for any reason but a graceful disconnect. (Well, there are others, but this is basically it). Combine this with your ssh-agent, and you can re-attach with easy. I also use &lt;a href="http://www.funtoo.org/Keychain"&gt;keychain&lt;/a&gt; to help manage my ssh-agent when I log in.&lt;/p&gt;

&lt;p&gt;Now that the connection will come back, I need a way to re-attach to my screen session, or if there is not one, to start one for me. To do&lt;br&gt;
that, I have this is my .bashrc file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;test -x $STY &amp;amp;&amp;amp; screen -xR
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will check to make sure that we are not already inside a screen session on the local host (&lt;em&gt;test -x $STY&lt;/em&gt;), and if we are not, then either attach to an existing screen session or start a new one (&lt;em&gt;screen -xR&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;I have define this function in my .bashrc to spawn a new ssh connection in a separate screen window:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function ss ()
{
  screen -t $1 ssh $*
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Easy stuff&lt;/p&gt;</description><category>cli</category><category>software</category><category>ssh</category><category>telecommute</category><guid>http://www.duckland.org/posts/200912making-life-easy-over-flaky-links.html</guid><pubDate>Mon, 28 Dec 2009 23:12:00 GMT</pubDate></item></channel></rss>