How to setup SFTP server on Ubuntu (Desktop) 20.04 | How to restrict an user to only SFTP

preview_player
Показать описание
Let us get into the steps – running all the commands in terminal

Step 1 : Install OpenSSH package if not installed

sudo apt install openssh-server

Step 2 : Create separate group for SFTP users.

sudo addgroup sftpgroup

Step 3 : Edit /etc/ssh/sshd_config file and make changes as below. I will be using the vim editor

Find and comment below line.

# Subsystem sftp /usr/lib/openssh/sftp-server

After commenting i saved the file, now again

and add these lines to the end of the file.

Subsystem sftp internal-sftp

Match group sftpgroup

ChrootDirectory %h

X11Forwarding no

AllowTcpForwarding no

ForceCommand internal-sftp

Step 4 : Restart sshd service.

sudo service ssh restart

Step 5 : Add user with ftpaccess group and create password.

sudo adduser sftpuser --ingroup sftpgroup --shell /usr/sbin/nologin

Step 6 : Modify home directory permission.

sudo chown root:root /home/sftpuser

Step 7 : Create a directory inside home for upload and modify permission with group.

sudo mkdir /home/sftpuser/sftpdir

sudo chown sftpuser:sftpgroup /home/sftpuser/sftpdir
Рекомендации по теме
Комментарии
Автор

man youtube is still the best place to find fixes. this is an awesome video!

Dainish
Автор

It is helpful perfectly. But I changed the sftp port as 2200 and opened port in inbound rule. It worked! Thank you.

toetoeag
Автор

wow very helpful my friend. Thank you very much!

crayyx
Автор

Worked perfectly for me - many thanks!

Oneplusfonti
Автор

Something change during the time. I did the extact steps but when I try to do a "ls", I get this error: remote readdir("/"): Permission denied

omarpinuelas
Автор

how to access files remotely, ? i mean if I am away from home network ? also how to add custom path to my external HDD

ydiadi_
Автор

Authentication log (see session log for details):
Using username "sftpuser".
Server refused our key.

Authentication failed.

cloudway
Автор

How can i give user to only download and only upload like this permision in sftp server? kindly help

nidheeshnle
Автор

Im getting an error after trying to login into the SFTP on WinSCP. Permission denied. Error code: 3, Error message from server: Permission denied.

rozowapianka
Автор

how can i access putty configuration ?

_uzyr
Автор

dont ever do this, if you only have ssh access to your server. it will lock you out

philh
Автор

can i connetect outside my local network with this?

Treybal.
Автор

erro after edit sshd_config. cant login

ramecesmagsisi
Автор

Will this affect me if im using a protected public key .cert to log in via putty? if i add my user to stfpuser group etc..?

hghpower
join shbcf.ru