How to set up an SFTP server on Linux

These steps walk you through the method of fitting associate SFTP server on UNIX for the secure transfer of files for specialized file transfer-only user.

CentOS seven or any UNIX system server distribution could be a terribly powerful server that performs higher than and on the far side what your business would possibly would like. no matter task you throw at the server, it’ll be prepared. And, if it is not prepared out of the box, you’ll be able to build it thus.

Take, for example, the power to simply put together CentOS seven to figure as associate SFTP server. If you are not certain concerning SFTP, it’s the FTP service designed into Secure Shell (SSH), which permits users to firmly push and pull files to and from the server, using SSH. With CentOS seven, there isn’t any third party code to put in to form this work–everything is put in out of the box. There is, however, a small little bit of work to be done to urge this designed.

I’m progressing to walk you thru the method of putting in associate SFTP server. It will demonstrate by making one user that’s restricted to solely SFTP logins. Once you recognize a way to do that, you’ll be able to produce as several users as you wish. It will be exploitation CentOS seven as my platform, however this method can work on any UNIX system distribution

Let’s make it work.

What you should have:

As I discussed, CentOS seven already has everything you wish, out of the box. What you want to have, however, is access to AN account with admin rights. Once you’ve got procured that access, it is time to form this work.

SFTP Directory:

The first factor we tend to should do is produce a directory that may house our FTP information. Open up a terminal window, su to the foundation user (type su so, once prompted, kind the foundation user password), and so issue the subsequent 2 commands:

mkdir -p /data

chmod 701 /data

Create the SFTP cluster and user:

Now we’re reaching to produce a special cluster for SFTP users. this can be through with the subsequent command:

groupadd sftp_users

Now we’re progressing to produce a special user that does not have regular login privileges, however will belong to our recently created SFTP_users cluster. What you decision that user is up to you. The command for this is:

useradd -g sftp_users -d /upload -s /sbin/nologin USERNAME

Where USERNAME is that the name of the user.

Next, provide the new user an Arcanum. This Arcanum is the Arcanum the new users use to log in with the SFTP command. To line up the Arcanum, issue the command:


Where USERNAME is the name of the user created above.

Create the new user SFTP directory:

Now we’re progressing to produce Associate in nursing transfer directory, specific to the new user, then offer the directory the right permissions. This is often handled with the subsequent commands:

mkdir -p /data/USERNAME/upload
chown -R root:sftp_users /data/USERNAME
chown -R USERNAME:sftp_users /data/USERNAME/upload

Where USERNAME is the name of the new user you created above.

Configure SSH:

Open up the SSH aemon configuration file with the command:

nano /etc/ssh/sshd_config

Save and close that file. Restart SSH with the command:

systemctl restart sshd

Logging in:

You’re ready to log in. From another machine on your network that has SSH put in, open up a terminal window and issue the command


Where USERNAME is that the name of our new user and SERVER_IP is that the informatics address of our SFTP server. you’ll be prompted for USERNAME’s word. Once you with success evidence, you’ll be greeted with the sftp prompt. Sort paw to visualize the operating path and you ought to see /upload (Figure 1.1):


A simple answer:

That’s all there’s to fixing associate SFTP server on UNIX system. For any company wanting to supply workers and purchasers a straightforward, secure means that of uploading and downloading files, this is often a not solely a good answer however conjointly terribly budget friendly one. Get your SFTP server up and running with zero value and 0 headaches.

Asad Mukhtar

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *