Ski*_*les 4 unix jail chroot sftp
我试图使用 rssh 将用户严格限制在他们的 /home/user/public_html 目录中。我让它在一个帐户可以在测试服务器上成功通过 SFTP 进入系统的地方工作,但是一旦我以该帐户登录,我注意到我可以将目录更改为我希望的任何位置并查看文件的内容。我可能无法编辑或转移到这些目录,但我认为能够监禁它们的全部目的是为了防止这种事情发生?
SSHD 设置子系统 sftp internal-sftp RSSH 指定用户只能使用 scp 和 sftp 用户帐户使用 /usr/bin/rssh 作为 shell 和 /home/user/public_html 用户的主目录是 root:用户所有者:组
我已经注意到,他们可以查看的唯一文件和他们可以 cd 进入的目录都是世界可读的,这是有道理的,但为什么他们完全允许离开他们的目录?请不要说我只是回答了我自己的问题。目的是找到防止这种情况的最佳实践解决方案。
期望的结果是限制他们对任何不属于他们的目录进行 cd 的能力。
我在这里错过了什么吗?
这是 rssh.conf 文件的内容;
logfacility = LOG_USER
allowscp
allowsftp
#allowcvs
#allowrdist
#allowrsync
#allowsvnserve
# set the default umask
umask = 022
user=wwwtest1:077:110000:/home/wwwtest1/public_html
Run Code Online (Sandbox Code Playgroud)
这是 sshd_config 文件的内容;
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
Run Code Online (Sandbox Code Playgroud)
如果您只需要 sftp,请不要理会 rssh 和创建 jail。如果您使用的是内部 sftp 服务器,最新版本的 openssh-server 可以为您 chroot sftp 用户。例如,如果您想将某个组的所有用户 chroot 到他们的主目录,您可以将其添加到 sshd_config:
Match Group sftp-only
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8388 次 |
最近记录: |