{"id":25,"date":"2012-09-01T19:24:07","date_gmt":"2012-09-01T17:24:07","guid":{"rendered":"http:\/\/catyellow.net\/blog\/?p=25"},"modified":"2012-09-27T21:49:04","modified_gmt":"2012-09-27T19:49:04","slug":"script-for-ssh-port-forwarding","status":"publish","type":"post","link":"https:\/\/catyellow.net\/blog\/?p=25","title":{"rendered":"Script for ssh port forwarding"},"content":{"rendered":"<p>Day to day I need to use ssh port forwarding and connect securely to my work servers. So I decided to create some simple bash script which will allow me to forward port via ssh and to kill previous tunnel if it freezed.<\/p>\n<p>Script source:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n#!\/bin\/bash\r\n# irc.sh\r\nkill -9 `ps -aef | grep -i 'ssh -f -N -L 1234:127.0.0.1:1234 user@hostname.com' | grep -v grep | awk '{print $2}'`\r\nssh -f -N -L 1234:127.0.0.1:1234 user@hostname.com\r\n\r\n<\/pre>\n<p><!--more--><\/p>\n<p>You can save this source code to any .sh file and run it manually from a command line, like this:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\ncd &lt;script destination&gt;\r\n.\/irc.sh\r\n\r\n<\/pre>\n<p>I didn&#8217;t want to do it only manually so I created a shortcut on my desktop to be able to run it quickly:<\/p>\n<p><a href=\"http:\/\/catyellow.net\/blog\/wp-content\/uploads\/2012\/09\/SSH-Fwd-Launcher-Properties.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-30\" src=\"http:\/\/catyellow.net\/blog\/wp-content\/uploads\/2012\/09\/SSH-Fwd-Launcher-Properties-300x148.png\" alt=\"\" width=\"300\" height=\"148\" srcset=\"https:\/\/catyellow.net\/blog\/wp-content\/uploads\/2012\/09\/SSH-Fwd-Launcher-Properties-300x148.png 300w, https:\/\/catyellow.net\/blog\/wp-content\/uploads\/2012\/09\/SSH-Fwd-Launcher-Properties.png 429w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Note, that I&#8217;m using key based SSH authentication.<br \/>\nMy OS is Linux Mint 13.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Day to day I need to use ssh port forwarding and connect securely to my work servers. So I decided to create some simple bash script which will allow me to forward port via ssh and to kill previous tunnel if it freezed. Script source:<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[7,6,5],"_links":{"self":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":7,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":40,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions\/40"}],"wp:attachment":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}