SFTP Configuration
What is SFTP?
SFTP (Secure File Transfer Protocol) is a file transfer protocol that leverages a set of utilities that provide secure access to a remote computer to deliver secure communications. It leverages SSH (Secure Socket Shell or Secure Shell) and is frequently also referred to as ‘Secure Shell File Transfer Protocol’.
Instructions
To install an SFTP server on a CENTOS Linux Server, follow the below steps:
- Execute the following command to check whether SSH is installed
1
2
3
|
sudo rpm -qa | grep ssh
|
- If SSH is not installed, run the following command
1
2
3
|
sudo yum install openssh-server
|
- Open port 22
1
2
3
|
sudo iptables -I INPUT -p tcp --dport 22 -j ACCEPT
|
- Create a user and provide new password for that user
1
2
3
4
5
|
sudo useradd {user_name}
sudo passwd {user_name}
|
- Create a directory for the file transfer and make the changes
1
2
3
4
5
6
7
|
sudo mkdir {directory_name}
sudo chgrp {user_name} {directory_name}
sudo chown {user_name} {directory_name}
|
- In /etc/ssh/sshd_config file add the below configuration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
Match User {user_name}
ForceCommand internal-sftp
PubkeyAuthentication yes
PasswordAuthentication yes
ChrootDirectory {directory_name}
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
|
- Restart the SFTP Service
1
2
3
|
sudo systemctl restart sshd.service
|
- Testing(provide password on prompted)
1
2
3
|
sftp {user_name}@{server_address}
|