I would like to mount a remote file system (A) using SSHFS, but sometimes I have IP address, access from which is not allowed. So my plan is to access it via another machine (B) in that network. Do I need to mount A on B and then to mount B (and A) on my local computer? Is there a better way to do it?
Update
Just to clarify the procedure:
First, I make a tunnel
ssh -f user@machineB -L MYPORT:machineA:22 -NAnd then I mount the remote file system
sshfs -p MYPORT user@127.0.0.1:/myremotepath /mylocalpathIs it correct?
How do I destroy the tunnel when I am done?
14 Answers
yeah tunneling. You connect machine B, create local tunnel (-L) to SSHd port of machine A then sshfs to localhost to the port of newly created tunnel.
3You can use option ssh_command of sshfs to do the trick:
sshfs ma: /mnt -o ssh_command='ssh -t mb ssh'Unmount with the usual
fusermount -u /mntSorry this is 7 years late...
2This is what works for me on HighSierra 10.13.6, SHFS version 2.5 (OSXFUSE SSHFS 2.5.0) OSXFUSE 3.10.4. FUSE library version: 2.9.7
Based on Rodrigo Farias's answer above + clemisch and Ohad Rubin comments for noting the -J option:
sshfs -p port finalserver_username@finalserver:/path/to/folder/on/finalserver/ /local/mount/point -o ssh_command='ssh -J intermediate_server_username@intermediate_server:port' 4 Your connection scheme:Your machine --> Host B --> Host A
Our solution will use Proxy Jump, introduced in OpenSSH 7.3, so you'll need to check that your version is newer with:
ssh -VThen you need to configure properly your ~/.ssh/config. For example, if machineB is available with a password login from machineA :
machineB HostName {machineB ip address} User {machineB username} Port {machineB port-number} IdentityFile ~/.ssh/{machineB private ssh key}
machineA ProxyJump machineB Hostname {machineA ip address, maybe in local network} User {machineA username} Port {machineA port-number}Finally, create your mountpoint and add line to /etc/fstab
machineB:{machineB mount path} {your local mountpoint} fuse.sshfs delay_connect,_netdev,user,idmap=user,follow_symlinks,identityfile={local path to machineB private key},default_permissions,uid={local user uid},gid={local user gid} 0 0 1