Secure Shell FileSystem (SSHFS) is a tool that allows users to securely access remote file systems using SSH. This guide will help you get started with SSHFS on Linode. SSHFS eliminates the need to transfer files between FTP/SFTP and remote servers. For this tutorial, you need to run the SSH daemon on Linode. If you do not have an SSH daemon, visit Secure Your Server before returning to this guide. For this tutorial, we used two Ubuntu 16.10 systems, but SSHFS can be installed on any Linode image.

Installing Required Software PackagesPermanent link

Before installing SSHFS, we need to update the system:

apt-get update && apt-get upgrade
Copy the code

Issue the following command to install SSHFS:

apt-get install sshfs
Copy the code

Pay attention to

The SSHFS package is available on every package manager, using commands specific to your distribution.

Set the Linux clientPermanent link

If you want to mount the file system using SSHFS with a normal user account, fuse first adds the user to the group.

Pay attention to

If you are unfamiliar with users, groups, and file permissions, be sure to visit users and groups for a brief introduction.

To check whether the FUSE group exists, run:

cat /etc/group | grep 'fuse'
Copy the code

If the group exists, execute the following command sudo and replace “someuser” with your user account name:

sudo usermod -a -G fuse someuser
Copy the code

If the group does not exist, you must create the FUSE group and add it to the group:

sudo groupadd fuse sudo usermod -a -G fuse user
Copy the code

Please log out and log back in before continuing with your regular user account.

Install the remote file systemPermanent link

To mount a remote file system, run the command SSHFS. The syntax SSHFS is:

sshfs [user@]host:[directory] mountpoint [options]
Copy the code
To mount the home directory of the user named "user" on the remote server of "usersLinode.example.com", create a directory as the target of the mounted folder.Copy the code
mkdir sshfsExample
Copy the code
We then use the SSHFS command to mount the directory from the remote server to the directory on the local client. The syntax of SSHFS is: hereCopy the code
sshfs [user@]host:[directory] mountpoint [options]
Copy the code

Read more about SSHFS: SSHFS Manual

sshfs [email protected]:/home/user ssfhsExample
Copy the code

You can also SSHFS use the IP address of your Linode server:

SSHFS [email protected]: / home/user sshfsExampleCopy the code

To unmount the file system, use the following umount command:

umount sshfsExample
fusemount -zu sshsExample
Copy the code

SSH keys and permanent installationFixed link

To install the server’s directory on the system through a reboot, you must create a persistent installation. You can change the SSH key directory to ensure that you do not need to enter a password to access the remote server. The SSH keys are stored in the remote authorized_keys file.

Pay attention to

If your system is older, you can name this file authorized_keys2. /etc/ssh/sshd_config If you are not sure, consult.

Replace the value applicable to your server in a command that contains a host name or user account name:

If the user account on the remote server does not already have the ~/.ssh key, issue this command on the remote server and accept the default value.

ssh-keygen -t rsa
Copy the code

If the SSH key ~/.ssh has not been installed on the user account of your local client, issue the same command on the client system and accept the default value:

ssh-keygen -t rsa
Copy the code

Issue the following command on the client system to copy the public SSH key to the remote server:

scp ~/.ssh/id_rsa.pub [email protected]:/home/user/.ssh/uploaded_key.pub
ssh [email protected] "echo `cat ~/.ssh/uploaded_key.pub` >> ~/.ssh/authorized_keys"
Copy the code

At this point, you should be able to log in to the remote server as “User” without entering a password. You can force mounted file systems to be persistent between reboots. This is done by including a mount directive in the remote user directory in /etc/fstab.

<sshfs#[email protected]>:/home/users /root/sshfsExample fuse defaults 0 0
Copy the code

This entry will install the home directory of “user” on the local server “usersLinode.example.com” every time /root/sshfsexample boots the system. You can treat this entry /etc/fstab just like any other entry.

The next stepPermanent link

After completing this tutorial, you will be able to transfer files from your local computer to a remote server without using an FTP client. If you still want to learn how to use an FTP client, check out our guide: Transferring files using FileZilla and see your favorite method.

For more informationFixed link

For additional information on this topic, you may want to refer to the following resources. While these are provided in the hope that they will be useful, please note that we cannot guarantee the accuracy or timeliness of externally hosted materials.

  • SSHFS home page
  • Linux security basics
  • SSH is used for public key authentication

Reference: www.linode.com/docs/networ…