{"id":879,"date":"2009-02-17T10:56:47","date_gmt":"2009-02-17T15:56:47","guid":{"rendered":"http:\/\/blog.alanporter.com\/2009-02-17\/ssh-netcat"},"modified":"2009-02-17T10:56:47","modified_gmt":"2009-02-17T15:56:47","slug":"ssh-netcat","status":"publish","type":"post","link":"https:\/\/alanporter.com\/blog\/2009\/02\/17\/ssh-netcat\/","title":{"rendered":"ssh + netcat"},"content":{"rendered":"<p>At work, I need to access some blade servers that are on a private network.  The only way to get into these machines is to shell into a lab box first, and then shell into a blade.<\/p>\n<pre>alan@desktop:~$ ssh root@labaccess\nLast login: Tue Feb 17 10:13:52 2009 from desktop\n[root@labaccess ~]# ssh root@blade3\nroot@blade3's password:-******\nLast login: Tue Feb 17 10:14:03 2009 from labaccess\n[root@blade3 ~]#<\/pre>\n<p>A while back, I picked up this little nugget from the TriLUG mailing list (thanks to Magnus Hedemark).  There is a way to make this intermediate hop automatically.  Simply add the following to $HOME\/.ssh\/config:<\/p>\n<pre>Host blade3 blade5 blade10\n    ProxyCommand ssh root@labaccess \"nc %h %p\" 2&gt;\/dev\/null<\/pre>\n<p>Now, when I try to ssh directly from my desktop to one of the blades, it first establishes an SSH session to the labaccess machine, and then netcat&#8217;s all of my original SSH traffic directly to the target blade.<\/p>\n<p>This process will ask you for 0, 1 or 2 passwords, depending on whether your public key (from <code>desktop<\/code>) is in the $HOME\/.ssh\/authorized_keys files on the <code>labaccess<\/code> and <code>bladeX<\/code> machines.  Since I have my public key on all of the machines, this is what I see now:<\/p>\n<pre>alan@desktop:~$ ssh root@blade3\nLast login: Tue Feb 17 10:17:21 2009 from labaccess\n[root@blade3 ~]#<\/pre>\n<p>This also means that I can <code>scp<\/code> files directly from my desktop to the blades, without having to dump them on the labaccess machine.<\/p>\n<p>By the way, this trick provides an EXCELLENT reason to consider re-flashing your home router with <a href=\"http:\/\/www.polarcloud.com\/tomato\">Tomato<\/a> firmware, which has ssh and netcat built-in.<\/p>\n<pre>Host homepc1 homepc2\n    ProxyCommand ssh root@router \"nc %h %p\" 2&gt;\/dev\/null<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>At work, I need to access some blade servers that are on a private network. The only way to get into these machines is to shell into a lab box first, and then shell into a blade. alan@desktop:~$ ssh root@labaccess Last login: Tue Feb 17 10:13:52 2009 from desktop [root@labaccess ~]# ssh root@blade3 root@blade3&#8217;s password:-****** [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,15,19],"tags":[],"class_list":["post-879","post","type-post","status-publish","format-standard","hentry","category-software","category-tips-tricks","category-work","count-0","even alt","author-alan","last"],"_links":{"self":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/comments?post=879"}],"version-history":[{"count":0,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/879\/revisions"}],"wp:attachment":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/media?parent=879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/categories?post=879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/tags?post=879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}