大网数据广告活动
服务器运维问答

sftp No supported authentication methods available

· 52CE 我爱测

I am trying to setup sftp to upload/download files from a specific directory (var/www/mysite.com) My issue is when I try to connect using Filezilla and I get an error stating No supported authentication methods available (server …

问题原文

原帖链接 · Jay · CC BY-SA 3.0

I am trying to setup sftp to upload/download files from a specific directory (var/www/mysite.com)

My issue is when I try to connect using Filezilla and I get an error stating

No supported authentication methods available (server sent: publickey)

So I think I missed a step when settup up and configuring sftp on my Ubuntu LAMP server. I should not I want to be able to sftp using a username and password and not a keyfile.

Here is what I did: Created user with password via SSH I then

sudo adduser <username> www-data

I then

sudo nano /etc/vsftpd.conf

and inside the file set chroot_local_user=YES and commented out chroot_list_enable=YES I then restarted sftp using:

sudo service vsftpd restart

I then configured the users directory sudo usermod -d /var/www/mydomain.com note I replaced with the username I created

I then

sudo nano /etc/ssh/sshd_config

and added the below to the bottom of the file

Subsystem  sftp  internal-sftp
Match user <username>
ChrootDirectory /var/www/mydomain.com
ForceCommand internal-sftp
AllowTcpForwarding no

and ensure that further up in the file that this is commented out (i.e before the one you just added)

#Subsystem sftp /usr/lib/openssh/sftp-server

I then restarted ssh using:

sudo service ssh restart

and changed permissions using:

chown root:root /var/www
chown root:root /var/www/mydomain.com
chmod 755 /var/www

Lastly I did:

sudo chown -R www-data:www-data /var/www/mydomain.com
chmod 755 /var/www/site

However I am not able to login to sftp via filezilla??

When I run the ssh command:

sftp -vvv user@servername

I get the below. I do not have a /secure in the var/log folder?

when I run the above commend I get this output

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

已采纳解答

原帖链接 · Jakuje · CC BY-SA 3.0

/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

You put these configuration options in the ssh_config instead of sshd_config. They are not valid in the first one.

sudo chown -R www-data:www-data /var/www/mydomain.com

This is also wrong, because the chroot directory has to be root-owned and not writable by any other user as explained in many answers and in manual page for sshd_config.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。