晓夏

YoungCheung

Zhang Sir's technical way

SFTP服务配置与使用

浏览量:200

1、修改sshd配置文件

$ vim /etc/ssh/sshd_config
#该行(上面这行)注释掉
#Subsystem sftp /usr/lib/openssh/sftp-server
# 添加以下几行
Subsystem sftp internal-sftp 
Match group sftp
#Match user test
#匹配sftp组,如为单个用户可用:Match user 用户名;  设置此用户登陆时的shell设为/bin/false,这样它就不能用ssh只能用sftp
ChrootDirectory /home/party
#指定用户被锁定到的那个目录,为了能够chroot成功,该目录必须属主是root,并且其他用户或组不能写
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

2、添加用户和用户组

$ groupadd sftp
$ useradd -d /home/party -m -s /bin/false -g sftp party

3、修改sftp用户密码

$ sudo passwd party

4、重启sshd服务

$ sudo systemctl restart sshd


神回复

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。