Install And Configure SFTP - Doubts

Hello,

I have some doubts concerning this task (Install And Configure SFTP - stapp01).

image

I tried following the path in the webpage: How to Setup Chroot SFTP in Linux (Allow Only SFTP, not SSH)

#Create group sftpusers
sudo groupadd sftpusers

#Create dir for user
$ mkdir -p /var/www/nfsdata

#Create User - The following command creates yousuf, assigns this user to sftpusers group, make /incoming as the home directory,
set /sbin/nologin as shell (which will not allow the user to ssh and get shell access).
sudo useradd -g sftpusers -d /var/www/nfsdata -s /sbin/nologin yousuf
sudo passwd yousuf

Pass LQfKeWWxWD

#Verify
id yousuf
cat /etc/group | grep sftpusers
cat /etc/passwd | grep yousuf

image

#Modify the the /etc/ssh/sshd_config file
sudo vi /etc/ssh/sshd_config file

#Subsystem sftp /usr/libexec/openssh/sftp-server (comment)
Subsystem sftp internal-sftp #(add)

#Specify Chroot Directory for a Group

tail /etc/ssh/sshd_config

Match Group sftpusers
ChrootDirectory /var/www/nfsdata
ForceCommand internal-sftp
PasswordAuthentication yes
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no

#Setup Appropriate Permission

chown yousuf:sftpusers /var/www/nfsdata

image

#restart service
sudo systemctl restart sshd

Problem is, I receive a “packet_write_wait: Connection to 172.16.238.10 port 22: Broken pipe”

image

No matter what I do, I can’t use sftp. Can anyone help me with this issue?

Thanks in advance,
Pedro Magalhães

the same error comes to me as well.

Guys you can try the below steps . It worked for me as well . I think you are missing the assigning of user pernissions .

Thanks

1 Like