{"id":1915,"date":"2015-08-20T16:07:32","date_gmt":"2015-08-20T15:07:32","guid":{"rendered":"https:\/\/stevepedwards.today\/DebianAdmin\/?p=1915"},"modified":"2015-08-20T16:07:32","modified_gmt":"2015-08-20T15:07:32","slug":"adding-a-ssh-share-during-an-open-ssh-session","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/DebianAdmin\/adding-a-ssh-share-during-an-open-ssh-session\/","title":{"rendered":"Adding a SSH Share Using SSHFS and Viewing Netstat"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1915\" class=\"pvc_stats all  \" data-element-id=\"1915\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>I just want to doc the basics of this and will add as I find more info, with the initial overview coming from:<\/p>\n<p><a href=\"https:\/\/www.howtogeek.com\/howto\/ubuntu\/how-to-mount-a-remote-folder-using-ssh-on-ubuntu\/\" target=\"_blank\">https:\/\/www.howtogeek.com\/howto\/ubuntu\/how-to-mount-a-remote-folder-using-ssh-on-ubuntu\/<\/a><\/p>\n<p><strong>Beware the line for changing ownership of \/dev\/fuse or any other fuse related commands at that link for Ubuntu! <\/strong><\/p>\n<p><strong>My Mint PC lost my user mdm (mint desktop manager) access so now I cannot log in to my user desktop!<\/strong><\/p>\n<p>I still haven't fixed it yet!<\/p>\n<p>I found I did NOT need to do any other than install sshfs in both Mint and Raspbian for sshfs to work and create a share on a remote host by opening a SSH session, so I don't know why the geek site had to <em>chown \/dev\/fuse<\/em> etc, but then I don't use Ubuntu.<\/p>\n<p>SSHFS works for a local network shared PC and the Internet.<\/p>\n<p>To solve the issue of Motion sending large appended time-lapse films - which is their nature - you can create real time .avi\u00a0files instead and access them remotely by still sending them manually as a sendemail attachment if you want of course, from the command line, after getting an SSH session going, or using SSHFS to create a local directory of the remote share.<\/p>\n<p>You only need the <span style=\"color: #0000ff;\"><strong>-o<\/strong>\u00a0<strong>nonempty<\/strong><\/span> switch if the share has sub-directories.<\/p>\n<p>This is of the form:<\/p>\n<p>$ <span style=\"color: #0000ff;\">sshfs root@pinoir:\/Share\/motion\/ \/remotenoir -o nonempty<\/span><\/p>\n<p>First:<\/p>\n<p><span style=\"color: #0000ff;\">apt-get install sshfs<\/span><\/p>\n<p>Open a SSH session to the remote PC:<\/p>\n<p><span style=\"color: #0000ff;\">ssh user@80.x.x.x<\/span><\/p>\n<p><span style=\"color: #ff0000;\">password etc.<\/span><\/p>\n<p>Organise your remote directory structure how you want that will mount to a local directory - where depends on who you are, whether root etc. e.g.<\/p>\n<p>On the local PC create a local mount point for the remote share e.g.:<\/p>\n<p><span style=\"color: #0000ff;\">mkdir \/home\/stevee\/Remblanc\/<\/span><\/p>\n<p>The command form is then:<\/p>\n<p><span style=\"color: #0000ff;\">sshfs root@80.x.x.x:\/Share\/motion\/ \/home\/stevee\/Remblanc\/ -o nonempty<\/span><\/p>\n<p>I don't like using commands relating to the (~) pwd, I use full paths as I find it less confusing, so the \/home\/stevee\/Remblanc\/ part of the above command is the LOCAL PC dir where the remote share will mount to.<\/p>\n<p>The \"\/Share\/motion\" part of the command is for the \/Share existing on the root dir of the remote linux PC, but note there is no space between the \"user@address:\/Share\" part of the command.<\/p>\n<p>When run, this just mounts the remote directory by\u00a0opening a new SSH session - great!<\/p>\n<p>Files on the remote PC can then be copied\/deleted etc. as any network share like Samba access allows, permissions depending. I did this as root first so I know if the command structure is correct first, and not a permission issue if it failed.<\/p>\n<p>In the case of Motion, I have the Pi cam writing its movies to the \/Share\/motion directory, so they are visible by samba - Win and Lin PCs locally - so can be viewed with VLC, or deleted etc. by any PC on my home network.<\/p>\n<p>I already opened ports on my router for the Picams streams, so I just added another NAT port for SSH (use a different port than 22 that only you would know for extra security if you like).<\/p>\n<p>I can now copy these to any remote PC I have SSH on, should I receive an email that motion has occurred and wish to view either jpgs or an .avi movie when at work by looking at the file size remotely, and judging if I want copy and view it or not.<\/p>\n<p>You can use GUIs for this too of course, or secure copy (SCP) if you want encryption with\u00a0a transfer, as shown in the link for Ubuntu GUIs above.<\/p>\n<p>I always like to know the command line ways primarily, should you be dealing with headless servers, and because it's efficient (mostly).<\/p>\n<p>What I found interesting is running netstat -nat - which is numeric, all, tcp -\u00a0to find the port 22 NAT translation does not show end to end between my work PC\u00a0and home router, but between a BT server (presumably the last hop gateway to my router) so the Inet address is NOT my home router WAN address that I get from my noip.com DynDNS account. This is confirmed by using a whois service webpage.<\/p>\n<p><span style=\"color: #0000ff;\">$ netstat -nat<\/span><br \/>\n<span style=\"color: #ff0000;\">Active Internet connections (servers and established)<\/span><br \/>\n<span style=\"color: #ff0000;\">Proto Recv-Q Send-Q Local Address Foreign Address State <\/span><br \/>\n<span style=\"color: #ff0000;\">tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN <\/span><br \/>\n<span style=\"color: #ff0000;\">tcp 0 224 <strong>192.168.1.13:22<\/strong> <strong>81.156.224.195:49032 ESTABLISHED<\/strong><\/span><br \/>\n<span style=\"color: #ff0000;\">tcp 0 0 <strong>192.168.1.13:22<\/strong> <strong>81.156.224.195:49041 ESTABLISHED<\/strong><\/span><\/p>\n<p><em>IP Address 81.156.224.195<\/em><br \/>\n<em>% Abuse contact for '81.154.0.0 - 81.157.255.255' is '\u00ef\u00bf\u00bc'<\/em><\/p>\n<p><em>inetnum: 81.154.0.0 - 81.157.255.255<\/em><br \/>\n<em>remarks: ***<\/em><br \/>\n<em>remarks: * Report abuse via: https:\/\/bt.custhelp.com\/app\/contact\/c\/346,3024 *<\/em><br \/>\n<em>remarks: ***<\/em><br \/>\n<em>netname: BT-CENTRAL-PLUS<\/em><br \/>\n<em>descr: IP pools<\/em><br \/>\n<em>country: GB<\/em><\/p>\n<p>MintRecPC stevee # <span style=\"color: #0000ff;\">netstat nat | grep ssh<\/span><br \/>\n<span style=\"color: #ff0000;\">tcp 0 0 192.168.1.11:48677 46.59.189.80.dyn.pl:ssh ESTABLISHED<\/span><\/p>\n<p>But if you run netstat nat (no - switch) to show NAT translations I believe, though can't find that in the man page or with --help, you DO get PC to router end to end info:<\/p>\n<p>MintRecPC stevee # <span style=\"color: #0000ff;\">netstat nat | grep ssh<\/span><br \/>\n<span style=\"color: #ff0000;\">tcp 0 0 192.168.1.11:48677 <strong>x.x.x.80<\/strong>.dyn.pl:ssh ESTABLISHED<\/span><\/p>\n<p>They are very\u00a0<em>different<\/em> commands if you look at the output or count the output lines between them:<\/p>\n<p>MintRecPC stevee # <span style=\"color: #0000ff;\">netstat nat | wc -l<\/span><br \/>\n<span style=\"color: #ff0000;\">420<\/span><\/p>\n<p>MintRecPC stevee # <span style=\"color: #0000ff;\">netstat -nat | wc -l<\/span><br \/>\n<span style=\"color: #ff0000;\">19<\/span><\/p>\n<p>These SSH connections can be persistent - they stayed attached even after logging out - I had to reboot to close them.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1915\" class=\"pvc_stats all  \" data-element-id=\"1915\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>I just want to doc the basics of this and will add as I find more info, with the initial overview coming from: https:\/\/www.howtogeek.com\/howto\/ubuntu\/how-to-mount-a-remote-folder-using-ssh-on-ubuntu\/ Beware the line for changing ownership of \/dev\/fuse or any other fuse related commands at that link for Ubuntu! My Mint PC lost my user mdm (mint desktop manager) access so <a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/adding-a-ssh-share-during-an-open-ssh-session\/\" class=\"more-link\">...<span class=\"screen-reader-text\">\u00a0 Adding a SSH Share Using SSHFS and Viewing Netstat<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1915","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"a3_pvc":{"activated":true,"total_views":2,"today_views":0},"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/1915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/comments?post=1915"}],"version-history":[{"count":0,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/1915\/revisions"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/media?parent=1915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/categories?post=1915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/tags?post=1915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}