How To Restart Sftp Service In Linux
These steps walk y'all through the process of setting upwardly an SFTP server on Linux for the secure transfer of files for specialized file transfer-only users.
Editor'due south note: The article was edited to correct username conventions within the commands.
CentOS 7 or whatsoever Linux server distribution is a very powerful server that performs above and beyond what your business organization might need. Whatever task you throw at the server, information technology will be ready. And, if it isn't set out of the box, you can go far and so.
Take, for instance, the power to easily configure CentOS 7 to work equally an SFTP server. If you aren't sure most SFTP, it is the FTP service congenital into Secure Trounce (SSH), which allows users to securely push and pull files to and from the server, using SSH. With CentOS 7, there'south no tertiary political party software to install to make this work–everything is installed out of the box. There is, yet, a slight chip of piece of work to exist done to get this configured.
I'm going to walk you through the process of setting upward an SFTP server. I'll demonstrate by creating a single user that is express to merely SFTP logins. Once you lot know how to practice this, y'all tin can create as many users equally you lot demand. I'll exist using CentOS 7 as my platform, but this process will work on whatsoever Linux distribution.
Permit's make information technology work.
What you lot'll need
As I mentioned, CentOS 7 already has everything you demand, out of the box. What you must have, nevertheless, is access to an account with admin rights. In one case you've procured that access, it's fourth dimension to make this piece of work.
SFTP Directory
The first matter we must do is create a directory that volition house our FTP information. Open upwards a final window, su to the root user (type su and and then, when prompted, blazon the root user countersign), and so issue the post-obit two commands:
mkdir -p /information
chmod 701 /data
Create the SFTP group and user
At present we're going to create a special group for SFTP users. This is washed with the following control:
groupadd sftp_users
Now nosotros're going to create a special user that doesn't accept regular login privileges, but does belong to our newly created sftp_users group. What y'all call that user is up to you. The command for this is:
useradd -chiliad sftp_users -d /upload -s /sbin/nologin USERNAME
Where USERNAME is the name of the user.
Adjacent, give the new user a countersign. This countersign volition exist the password the new users use to log in with the sftp command. To set upwards the password, outcome the command:
passwd USERNAME
Where USERNAME is the proper name of the user created higher up.
Create the new user SFTP directory
Now we're going to create an upload directory, specific to the new user, and then give the directory the proper permissions. This is handled with the following 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 proper name of the new user you created above.
Configure sshd
Open up the SSH daemon configuration file with the command:
nano /etc/ssh/sshd_config
At the lesser of that file, add the following:
Match Grouping sftp_users
ChrootDirectory /data/%u
ForceCommand internal-sftp
Save and close that file. Restart SSH with the command:
systemctl restart sshd
Logging in
You lot're all set to log in. From another car on your network that has SSH installed, open up upward a last window and issue the control:
sftp USERNAME@SERVER_IP
Where USERNAME is the proper name of our new user and SERVER_IP is the IP accost of our SFTP server. You will be prompted for USERNAME's password. Once you successfully authenticate, yous will exist greeted with the sftp prompt. Blazon pwd to check the working path and you lot should see /upload (Figure A).
Figure A
A elementary solution
That'south all there is to setting up an SFTP server on Linux. For any company looking to offer staff and clients a uncomplicated, secure means of uploading and downloading files, this is a not only a corking solution but also very budget friendly ane. Get your SFTP server up and running with zippo cost and zero headache.
Source: https://www.techrepublic.com/article/how-to-set-up-an-sftp-server-on-linux/
Posted by: mcleanaparich.blogspot.com
0 Response to "How To Restart Sftp Service In Linux"
Post a Comment