Friday, April 24, 2026
HomeCyber SecurityHow you can use SSHFS to mount distant directories on Rocky Linux

How you can use SSHFS to mount distant directories on Rocky Linux

[ad_1]

Learn how to mount a distant listing on a Rocky Linux server to an area listing with the assistance of SSHFS.

SSH over servers
Picture: Funtap/Shutterstock

SSHFS (SSH File System) makes it attainable to mount distant filesystems through an SSH connection. SSHFS makes use of SFTP (SSH File Switch Protocol) to mount a distant listing on an area machine such that the connection between the shopper and server is encrypted. Due to that, SSHFS can be utilized as a safer resolution for conventional FTP.

SEE: 5 programming languages community architects ought to study (free PDF) (TechRepublic)

I need to stroll you thru the set up and utilization of SSHFS on Rocky Linux.

What you’ll want

To make this work, you’ll want a working occasion of Rocky Linux, a shopper machine that may use SSH, and a person with sudo privileges.

Let’s make some magic.

How you can set up SSHFS

The very first thing we should do is set up SSHFS. Log into your Rocky Linux server and first improve it with the command:

sudo dnf improve -y

As soon as the improve completes, reboot (however provided that the kernel was upgraded) after which set up SSHFS with the command:

sudo dnf set up fuse-sshfs -y

Subsequent, on the shopper machine, set up SSHFS. In the event you’re u

How you can create mountable directories

First, let’s create a listing on the server that can then be mounted on the shopper machine. To create the listing on the server, challenge the command:

sudo mkdir /srv/information

Subsequent, change the permissions of the brand new listing such that the required person can entry it with the command:

sudo chown -R $USER.$USER /srv/information

If multiple person wants entry to this listing, you’d must create a brand new group, add the customers to the group, after which give the group entry to the listing. Let’s say you need to create a bunch named editorial and provides them entry to that new listing. First, create the group with:

sudo groupadd editorial

sudo usermod -aG editorial $USER

sudo chgrp -R editorial /srv/information

On the native machine, create a brand new listing (one which might be used to mount the distant listing into) with the command:

mkdir ~/data_mount

How you can mount the distant listing to the native machine

It’s time to mount the distant listing to the native machine. On the shopper challenge the command:

sshfs USER@SERVER:/srv/information ~/data_mount

The place USER is the person on the distant machine and SERVER is the IP handle or area of the distant server and also you’ll be prompted for the person’s password. Upon profitable authentication, you’ll get your immediate again and the mount is prepared for use.

How you can make the mount everlasting

It is a bit difficult since you first should arrange SSH key authentication. To try this, on the shopper machine create the SSH key with:

ssh-keygen -t rsa

As soon as the bottom line is generated, copy it to the distant server with:

ssh-copy-id USER@SERVER

The place USER is the username and SERVER is both the IP handle or area of the distant server. As soon as the bottom line is copied, take a look at the reference to:

ssh USER@SERVER

The place USER is the username and SERVER is both the IP handle or area of the distant server. You need to be prompted for the SSH key authentication password. Exit from the join and take a look at it once more. This time you shouldn’t be prompted as a result of the important thing has been saved in your keychain.

Now you can create an fstab entry for the SSHFS connection. Open that file (on the shopper) for modifying with:

sudo nano /and many others/fstab

On the backside of that file, add the next line:

USER@SERVER:/srv/information /dwelling/USER/data_mount   fuse.sshfs  delay_connect,_netdev,person,idmap=person,transform_symlinks,identityfile=/dwelling/jack/.ssh/id_rsa,default_permissions,uid=USER_ID,gid=USER_GID   0 0

The place USER is the username, SERVER is both the IP handle or area of the distant server, USER_ID is the ID of the person, and USER_GID is the group ID of the person. You may find the IDs by issuing the command:

id

Save and shut the file. Take a look at the mount with:

mount -a

It is best to obtain no errors.

The caveat to that is that the distant listing received’t be mechanically mounted at boot. It is because it requires a community connection to be loaded first. Nevertheless, when you log into the machine, you’ll be able to merely challenge the command:

mount -a

It’s a little bit of a problem, however I’ve but to give you a strong resolution to get this to work with out utilizing passwordless ssh key authentication (which we don’t need to use due to safety points).

Anyway, that’s all there’s to mounting a distant listing with SSHFS on Rocky Linux.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise execs from Jack Wallen.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments