{"id":350,"date":"2013-04-15T10:08:37","date_gmt":"2013-04-15T15:08:37","guid":{"rendered":"http:\/\/bitc.bme.emory.edu\/~lzhou\/blogs\/?p=350"},"modified":"2013-04-15T15:09:47","modified_gmt":"2013-04-15T20:09:47","slug":"using-ssh-tunnel-to-port-nfs-through-firewall-and-private-network","status":"publish","type":"post","link":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/?p=350","title":{"rendered":"Using ssh tunnel to port NFS through firewall and private network"},"content":{"rendered":"<p>network structure:<br \/>\nmachine1 &gt;&gt; firewall &gt;&gt;&gt;- Internet -&gt; machine2  nfs_server<\/p>\n<p>Step 1: on nfs_server, add line in \/etc\/exports:<br \/>\n nfs_dir 127.0.0.1(rw,async,insecur)<br \/>\nAlso, add line in \/etc\/sysconfig\/nfs<br \/>\n MOUNTD_PORT &lt;port_number3<br \/>\nThe port_number3 is a large number, for example, 32334,<br \/>\nThen do &quot;service nfs restart&quot;<br \/>\nThis allows the nfs mount point is accessible from the box itself;<\/p>\n<p>Step 2: on machine2, which can see its intranet node nfs_server, create two ssh tunnel:<br \/>\n$ ssh username@nfs_server -L :localhost:2049 -f sleep m<br \/>\n$ ssh username@nfs_server -L :localhost: -f sleep m <\/p>\n<p>The  should be replaced by a number of minutes you&#8217;d like the tunnel to open.<br \/>\nFor example, 1440m for 24 hours.<br \/>\nThe port_number1 and port_number2 are ports for the communication.<\/p>\n<p>Step 3: on machine1, which can ssh machine2, however, machine2 cannot ssh machine1 because of the firewall, do<br \/>\n$ ssh username@machine2 -L :localhost: -f sleep m<br \/>\n$ ssh username@machine2 -L :localhost: -f sleep m <\/p>\n<p>Step 4: on machine1, mount the nfs share:<br \/>\n$ mount -v -t nfs -o port=,mountport=,tcp localhost:\/nfs_dir\/ \/mnt\/mount_point\/<br \/>\nwhere \/nfs_dir\/ is the name of the shared directory on nfs_server, and \/mnt\/mount_point\/ is a local directory<br \/>\nas the mounting point.<\/p>\n<p>Why mount localhost:\/nfs_dir\/?  The reason is that the certain ports on localhost have been tunnelled through ssh<br \/>\nto the remote nfs server.<\/p>\n<p>Note:<br \/>\nFor a ssh tunnel that allows reverse ssh back from machine2 to machine1:<br \/>\n$ ssh user@machine2 -R :localhost:22 -f sleep m<\/p>\n","protected":false},"excerpt":{"rendered":"<p>network structure: machine1 &gt;&gt; firewall &gt;&gt;&gt;- Internet -&gt; machine2 nfs_server Step 1: on nfs_server, add line in \/etc\/exports: nfs_dir 127.0.0.1(rw,async,insecur) Also, add line in \/etc\/sysconfig\/nfs MOUNTD_PORT &lt;port_number3 The port_number3 is a large number, for example, 32334, Then do &quot;service nfs restart&quot; This allows the nfs mount point is accessible from the box itself; Step 2: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,3],"tags":[],"class_list":["post-350","post","type-post","status-publish","format-standard","hentry","category-computer-tips","category-mri-technical-support","post-blog"],"_links":{"self":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=350"}],"version-history":[{"count":3,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions"}],"predecessor-version":[{"id":352,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions\/352"}],"wp:attachment":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}