You are here

How to Mount a Remote Folder Using SSH & SFTP Without NFS or Samba


How to Mount a Remote Folder Using SSH & SFTP Without NFS or Samba

Looking for a way to seamlessly connect your local and remote systems? Today, I'll guide you through a simple, yet effective, method that harnesses the power of SSH and SFTP. You won't even need tools like NFS or Samba.

Benefits of Using SSH and SFTP for Remote Folder Mounting

  • Security: With SSH, you get encrypted communication.
  • Simplicity: Avoid complex configurations of tools like Samba or NFS.
  • Flexibility: Great for various use-cases where you need to access remote data as if it's local.

Step-by-Step Guide to Mounting with SSHFS

  • Installation: On an Ubuntu system (other distributions might slightly differ), start by installing sshfs. Ensure you have root privileges.
apt install sshfs
  • Basic Mounting: Here’s how to mount a remote folder quickly:

sshfs [email protected]:/home/sanglyb /mnt
sshfs -o IdentityFile=~/.ssh/id_rsa [email protected]:/home/sanglyb /mnt
  • Custom SSH Ports: Using a non-standard SSH port? No problem!

sshfs -p 10022 -o IdentityFile=~/.ssh/id_rsa [email protected]:/home/sanglyb /mnt
  • Auto-mounting with SSHFS: Want the folder to mount automatically? Add this line to /etc/fstab:

sshfs#[email protected]:/home/sanglyb /mnt fuse defaults,idmap=user,port=22,allow_other,reconnect,_netdev,users,identityfile=/root/.ssh/id_rsa 0 0

Then, either reboot or run:

mount -a
  • Unmounting: To disconnect:

umount /mnt

Troubleshooting:

Encounter the "fuse: bad mount point `/mnt': Transport endpoint is not connected" error? Resolve it with:

fusermount -u /mnt

Conclusion:

Mounting a remote folder using SSH and SFTP is a straightforward and secure method. Whether you're a system admin or a tech enthusiast, this approach can make your operations efficient and hassle-free. Don't forget to share this guide with friends or colleagues who might benefit!

0 0

Share the article with your friends in social networks, maybe it will be useful to them.


If the article helped you, you can >>thank the author<<