1. 创建一个目录,owner为root,权限为750或755,此处为 /home/test01

添加一个用户test01,home目录设置为 /home/test01

再创建一个子目录用于用户上传:/home/test01/upload,owner为test01,

$ mkdir /home/test01
$ chown root:test01 /home/test01
$ mkdir /home/test01/upload
$ chown test01:test01 /home/test01/upload

 

2. 增加一个组 sftponly

$ groupadd sftponly

将test01的用户组设置为sftponly,并且设置为无ssh权限

$ usermod –G sftponly -s /sbin/nologin test01

 

2. 修改 /etc/ssh/sshd_config

修改 Subsystem:

#Subsystem      sftp    /usr/libexec/openssh/sftp-server
Subsystem      sftp    internal-sftp

添加配置:

Match Group sftponly
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no

 重启sshd服务

$ service sshd restart

 

相关文章:

  • 2022-12-23
  • 2021-11-14
  • 2021-09-06
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-24
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案