Hi, today we’ll discuss about SFTP Server. SFTP stand for secure File Transfer Protocol. For the Setup sftp server linux, you can secure your system more. Sometimes it is highly recommended to use SFTP protocol in the file transfer service. It is considered as most secure file transfer system, because, there is a encryption technique between the client and the FTP server.
Setup sftp server linux
So to active the SFTP service we basically need the openssh server. If it is previously installed in your server then you need not to install it again. But if it is not installed then you need to install it. So we may consider that in our server openssh is not installed. So lets install it.
[root@localhost ~]# yum -y install openssh-server
Now you need to create a separate group for the FTP server and the access to the server.
[root@localhost ~]# groupadd ftpgrp
Now we need to open the openssh configuration file and need to make some change in it. You can make change as following:
Find and comment the below line ( Line no : 147 ).
#Subsystem sftp /usr/libexec/openssh/sftp-server
and add these lines below.
Match group ftpgrp
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Now we need to restart the openssh server and its service.
[root@localhost ~]# systemctl restart sshd
So we can say that our service is configured and it is ready for work.
Now, what we can do, we can create user for the group we have created named as ftpgrp
[root@localhost ~]# useradd -m jim -s /sbin/nologin -g ftpgrp
[root@localhost ~]# passwd jim
So we have successfully created user. And now we need to change the permission of this user using the root user. Lets do this:
[root@localhost ~]# chown root /home/jim
[root@localhost ~]# chmod 750 /home/jim
Now lets create a directory in the www inside the home directory to change or modify the ownership.
[root@localhost ~]# mkdir /home/jim/www
[root@localhost ~]# chown jack:ftpgrp /home/jim/www
So the process completed, now you can access the SFT server using this new account. You may use different types of FTP client like Filezilla.
Now you may have a question in your mind that, we’ve made a FTP and SFTP server, so how a user can get access to both the servers. You just need to change the permission. From the previous post of FTP configuration, you may find that, we’ve created a user named jim. So we need to give jim user to access the newly created group of SFTP. Lets do this.
[root@localhost ~]# usermod jim -g ftpgrp
[root@localhost ~]# chown root /home/jim
[root@localhost ~]# chmod 750 /home/jim
[root@localhost ~]# mkdir /home/jim/www
[root@localhost ~]# chown jim:ftpgrp /home/jim/www
So we’ve successfully done this step. Hope that after this post, you will be able to configure SFTP server perfectly. If you have any kinds of question related to this post, then please feel free to comment. Have a nice day. 🙂
Leave a Reply