sftp配置多個用戶權限的問題


groupadd group1

chmod 0755 /test/
useradd -g group1 -d /test/backend/ -M test_backend
usermod -s /sbin/nologin test_backend
passwd test_backend
xxxxxxxx

useradd -g group1 -d /test/api/ -M test_api
usermod -s /sbin/nologin test_api
passwd test_api
xxxxxx

useradd -g group1 -d /test/business/ -M test_business
usermod -s /sbin/nologin test_business
passwd test_business
xxxxxx


vi /etc/ssh/sshd_config

UseDNS no
AddressFamily inet
SyslogFacility AUTHPRIV
PermitRootLogin yes
PasswordAuthentication yes

# override default of no subsystems
# Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp

Match User test_backend
ChrootDirectory /test/backend
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Match User test_api
ChrootDirectory /test/api
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Match User test_business
ChrootDirectory /test/business
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

systemctl restart sshd

 

這里有幾點

1、主目錄的所有者必須為root

即 chown root:root /test

2、權限為chmod 755 /test

3、要想讓sftp修改子目錄,只能創建子目錄來設置權限

mkdir /test/api/project01

chown test_api:group1 /test/api/project01

chmod 755 /test/api/project01


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM