我试图使用rssh严格监禁用户的/ home / user / public_html dirctories。 我得到它的工作,一个帐户可以在testing服务器上SFTP成功的系统,但一旦我login为该帐户,我注意到,我可以改变目录到任何地方我希望和查看文件的内容。 我可能无法编辑或转移到这些目录,但我认为能够监禁他们的全部目的是防止这样的事情?
SSHD使用子系统sftp internal-sftp设置RSSH具有用户指定为只能使用scp和sftp用户的帐户使用/ usr / bin / rssh作为shell和/ home / user / public_html用户的主目录是root:用户所有者:小组
我注意到,虽然他们可以查看内容和目录,他们可以进入唯一的文件都是世界可读的,这是有道理的,但为什么他们允许离开他们的目录呢? 请不要只说我自己的问题。 目的是find防止这种情况的最佳实践解决scheme。
期望的结果是,它们限制了任何不属于它们的目录的能力。
我在这里错过了什么?
这里是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
这里是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
如果你需要的只是sftp,不要打扰rssh和创build监狱。 如果您正在使用internet sftp服务器,则最新版本的openssh-server可以为您创buildsftp用户。 例如,如果要将某个组的所有用户都chroot到其主目录,则可以将其添加到sshd_config中:
Match Group sftp-only ChrootDirectory %h ForceCommand internal-sftp AllowTcpForwarding no
设置rssh并不重要。 你基本上必须build立一个chroot /监狱与二进制文件/库/configuration任何你要在监狱里运行的任何东西。
在Debian系统中,有一些工具可以像makejail或者rssh docs目录中包含的脚本/usr/share/doc/rssh/examples/mkchroot.sh 。
如果还没有,请查看/usr/share/doc/rssh/下的所有与rssh相关的文档,以及rssh和rssh.conf的手册页。您应该特别注意的一个文档是要查看的CHROOT文件它运行zless /usr/share/doc/rssh/CHROOT.gz 。
如果您试图限制您的用户,他们是否真的需要shell访问? 还是完全限制他们sftp一个有效的select? 如果他们只需要传输文件,那么请参阅此服务器默认search的结果。 ( ForceCommand internal-sftp )
这听起来像你已经正确安装,除了rssh.conf文件中的用户定义。 它应该被设置为:
user=wwwtest1:077:000110:/home/wwwtest1/public_html
为了给SCP或SFTP,而不是:
user=wwwtest1:077:110000:/home/wwwtest1/public_html
只能访问CVS,Rsync和Rdist。
尝试scponly 。 这是一个特殊的shell,只能启用scp而不是ssh,而且它也有一个chrooted版本的scponlyc 。