我想安装SFTP上传/下载文件从一个特定的目录(var / www / mysite.com)
我的问题是,当我尝试连接使用Filezilla,我得到一个错误说明
没有支持的authentication方法可用(服务器发送:publickey)
所以我想我在Ubuntu LAMP服务器上安装和configurationsftp时错过了一个步骤。 我不应该希望能够使用用户名和密码,而不是密钥文件。
这是我做的:然后通过SSH创build用户密码
sudo adduser <username> www-data
那我
sudo nano /etc/vsftpd.conf
并在文件里面设置chroot_local_user=YES并注释掉chroot_list_enable=YES然后我重新启动sftp使用:
sudo service vsftpd restart
然后我configuration了用户目录sudo usermod -d /var/www/mydomain.com注意我用我创build的用户名replace
那我
sudo nano /etc/ssh/sshd_config
并将下面的内容添加到文件的底部
Subsystem sftp internal-sftp Match user <username> ChrootDirectory /var/www/mydomain.com ForceCommand internal-sftp AllowTcpForwarding no
并确保进一步在文件中,这是注释掉( 即之前,你刚刚添加)
#Subsystem sftp /usr/lib/openssh/sftp-server
然后我重新启动ssh使用:
sudo service ssh restart
并使用以下方式更
chown root:root /var/www chown root:root /var/www/mydomain.com chmod 755 /var/www
最后我做了:
sudo chown -R www-data:www-data /var/www/mydomain.com chmod 755 /var/www/site
但是我不能通过filezillalogin到SFTP?
当我运行ssh命令时:
sftp -vvv user@servername
我得到下面。 我在var / log文件夹中没有/ secure?
当我运行上面的表示我得到这个输出
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * /etc/ssh/ssh_config: line 57: Bad configuration option: usepam /etc/ssh/ssh_config: line 58: Bad configuration option: subsystem debug2: checking match for 'user <username>' host *****.com originally *****.com debug3: /etc/ssh/ssh_config line 59: not matched 'user "*****"' debug2: match not found /etc/ssh/ssh_config: line 60: Bad configuration option: chrootdirectory /etc/ssh/ssh_config: line 61: Bad configuration option: forcecommand /etc/ssh/ssh_config: line 62: Bad configuration option: allowtcpforwarding /etc/ssh/ssh_config: terminating, 5 bad configuration options Couldn't read packet: Connection reset by peer
/etc/ssh/ssh_config: line 60: Bad configuration option: chrootdirectory /etc/ssh/ssh_config: line 61: Bad configuration option: forcecommand /etc/ssh/ssh_config: line 62: Bad configuration option: allowtcpforwarding /etc/ssh/ssh_config: terminating, 5 bad configuration options
你把这些configuration选项放在ssh_config而不是sshd_config 。 他们在第一个是无效的。
sudo chown -R www-data:www-data /var/www/mydomain.com
这也是错误的,因为chroot目录必须是root拥有的,不能被任何其他用户写入,如许多答案和sshd_config手册页中所述。