Selected from Linux Selected from PHP
- Ubuntu 17.10 Install google's mod pagespeed for apache - PHP-Ubuntu-Youtube-dl simple script for converting and downloading youtube video or mp3
- Ubuntu SSH tunnel via proxy - PHP while loop with every row with a different color
- Install GoAccess Apache Log Analyzer Tool on Ubuntu 17.10 - PHP use while loop in function
- SSHFS and map folder with a proxy - PHP List Files And Folders As links
- How to connect to SSH server with a proxy - PHP Extract Text From String
➥ sshfs and map folder with a proxy
Added by sonik on 22-06-2018 and keywords: [ Print Article ]
In many cases it can become cumbersome to transfer files to and from a droplet. Imagine a development usage scenario where you are coding apps remotely and find yourself uploading a script repeatedly to your virtual server to test. This can become quite a hassle in a very short period of time. Luckily there is a way to mount your VPS file system to your local computer so you can make changes on the fly and treat your droplet as local storage. In this article, we will show you how to do exactly that.

Configure ssh key-based authentication
Generate key pair on the local host with your username.

$ cd /home/yourprofile/.ssh
$ ssh-keygen -t rsa -b 4096

Accept all sugestions with enter key.

Copy public key to the remote host:

$ ssh-copy-id -i .ssh/ user@host

Install sshfs

$ sudo apt install sshfs

Mount remote directory

$ mkdir /home/yourUserName/remotefoldername
$ chmod 777 /home/yourUserName/remotefoldername
$ sshfs user@host:/remote_directory /local_directory -o "ProxyCommand=nc -X connect -x %h %p"

Don't try to add remote fs to /etc/fstab
Or don't try to mount shares via /etc/rc.local .
In both cases it won't work as the network is not available when init reads /etc/fstab.

Install AutoFS

$ sudo apt install autofs

Edit /etc/auto.master

Comment out the following lines


Add a new line

/- /etc/auto.sshfs --timeout=30

Save and quit

Edit /etc/auto.sshfs

Add a new line

/local_directory -fstype=fuse,allow_other,IdentityFile=/local_private_key :sshfs\#user@remote_host\:/remote_directory

Remote user name is obligatory.

Save and quit

Start autofs in debug mode

$ sudo service autofs stop
$ sudo automount -vf

Observe logs of the remote ssh server

$ ssh user@remote_server
$ sudo tailf /var/log/secure

Check content of the local directory

You should see contents of the remote directory

Start autofs in normal mode

Stop AutoFS running in debug mode with CTRL-C .

Start AutoFS in normal mode

$ sudo service autofs start

@All rights reserved with Copyright 2018 by Sonik_Blast [ Site Map ] [ RSS ] [ YouTube Mp3 Downloader and converter ]