使用以下软件的Linux服务器:
- Ubuntu 10.04 LTS x64 - Linux kernel 2.6.38
需要以下configuration/软件:
- SSH through rsa key authentication - SFTP with the following properties: - Single user - Access to ONLY /var/www (no home directory what so ever) - Rsa key authentication
服务器将在互联网上,所以它需要安全。 我该如何正确地做到这一点? 我遇到了SFTP用户的configuration,他可以访问FTP但不能写任何东西,也不能下载。 我想我做错了chown或权限设置不正确,我只是无法弄清楚是什么导致了这个问题。
sudo apt-get install openssh-server sudo mkdir /var/www sudo groupadd sftp_users sudo useradd -d "/var/www" --groups sftp_users -s /bin/false -p '!' "root_sftp" sudo passwd root_sftp sudo chmod 751 /var/ sudo chmod 770 /var/www sudo chown root:root_sftp /var/www sudo nano /etc/ssh/sshd_config
在sshd_configuration文件中添加/更改了以下内容
PermitRootLogin no AuthorizedKeysFile /etc/ssh/authorized_keys PermitEmptyPasswords no PasswordAuthentication yes Subsystem sftp internal-sftp Match User root_sftp ChrootDirectory /var/www ForceCommand internal-sftp X11Forwarding no AllowTcpForwarding no PermitRootLogin no AllowAgentForwarding no
现在问题再次出现,用户可以用一个密钥login,SSH也正常工作,但SFTP工作不正常。
用户可以使用SFTP(我使用filezilla)login,但他不能上传等等。似乎用户只有执行位( – x或1)
我真的希望有人能帮助我,我已经花了很长时间来configuration。 感谢您的帮助和时间。
提取root权限,/ var和/ var / www
# ls -lad / /var /var/www drwxr-xr-x 22 root root 4096 2012-03-13 22:59 / drwxr-x--x 15 root root 4096 2012-03-13 23:04 /var drwxrwx--- 3 root root_sftp 4096 2012-03-13 23:15 /var/www
/ var / www目录是空的。
作为根:
mkdir /var/www/files chown root_sftp:sftp_users /var/www/files
你的SFTP用户可以把文件放在chroot下面显示为/ files的文件中吗? 我不记得立即回想起来,但是我认为你不可能因为chroot监狱而对这件事情表示怀疑。
更新:
啊,它实际上在sshd_config的手册页中:
ChrootDirectory Specifies a path to chroot(2) to after authentication. This path, and all its components, must be root-owned directories that are not writable by any other user or group.
因此,在/ etc / ssh / sshd_config中指定为ChrootDirectory的内容不能写入。 您可以重新考虑您的目录设置,那么您网站的文档根目录是/var/www/example.com,其中example.com子目录可由SFTP用户写入。