Ubuntu пользователь FTP доступ

1396
tadywankenobi

Реальные проблемы с ftp-доступом к моему облачному VPS-решению для Ubuntu.

Я пробовал как vsftpd, так и чистый ftpd. Я обнаружил, что оба были ограничены. Я теперь попытался сосредоточиться на vsftpd, поскольку это хорошо получено.

Я попытался следовать инструкциям здесь:

http://ubuntuforums.org/showthread.php?t=518293

Единственное, что я пока не сделал в этом руководстве, - это добавление правил TLS / SSL / FTPS, поскольку у меня возникают проблемы при добавлении порта 990 в настройки брандмауэра сервера. Это было помечено моим провайдером и, надеюсь, будет решено вовремя.

Первоначально я использовал пользователей, которые имели доступ к оболочке. Это позволяло пользователю войти в систему и получить доступ к серверу и правильным папкам, но не мог записывать новые файлы или перезаписывать существующие файлы на сервере. Они могли создавать папки и удалять файлы. Когда я вошел в систему с учетными записями оболочки с помощью командной строки ftp, я мог без проблем записать (mput) файлы на сервер, но я ожидаю, что это из-за того, что командная строка ftp работает в отличие от службы ftp.

Я думал, что моя проблема может заключаться в том, что мои пользователи могут не иметь доступа, поскольку у них есть доступ к оболочке. Затем я создал нового пользователя без доступа к оболочке. Я не могу войти с этими пользователями. Я получаю 530 Неверный логин, хотя я изменил и проверил пароль. Я не могу войти с помощью командной строки ftp.

Я включил ниже мой файл vsftpd.conf. Я попробовал пользовательский, но в итоге вернулся к оригиналу, просто чтобы начать заново. Я добавил директиву check_shell = NO, чтобы посмотреть, помогло ли это. Я начал с добавления виртуальных пользователей в систему, но я не понимаю, как это что-то изменит.

Я буквально провел все выходные, пытаясь решить эту проблему, но безрезультатно.

Вот содержимое / etc / shadow (-hashed pwds). Два новых пользователя: spdftp и scftp:

root:xxxx:15607:0:99999:7::: daemon:*:15104:0:99999:7::: bin:*:15104:0:99999:7::: sys:*:15104:0:99999:7::: sync:*:15104:0:99999:7::: games:*:15104:0:99999:7::: man:*:15104:0:99999:7::: lp:*:15104:0:99999:7::: mail:*:15104:0:99999:7::: news:*:15104:0:99999:7::: uucp:*:15104:0:99999:7::: proxy:*:15104:0:99999:7::: www-data:*:15104:0:99999:7::: backup:*:15104:0:99999:7::: list:*:15104:0:99999:7::: irc:*:15104:0:99999:7::: gnats:*:15104:0:99999:7::: nobody:*:15104:0:99999:7::: libuuid:!:15104:0:99999:7::: syslog:*:15104:0:99999:7::: sshd:*:15104:0:99999:7::: mysql:!:15104:0:99999:7::: postfix:*:15424:0:99999:7::: clamav:!:15425:0:99999:7::: amavis:*:15425:0:99999:7::: vmail:!:15425:0:99999:7::: dovecot:*:15425:0:99999:7::: vsftpd:!:15724:0:99999:7::: ftpuser:!:15752:0:99999:7::: ftp:*:15752:0:99999:7::: spdftp:xxxx:15754:0:99999:7::: scftp:xxxx:15754:0:99999:7::: 

Вот вывод файла / etc / passwd для этих пользователей:

spdftp:x:5005:1002::/var/www/path/to/home:/bin/sh scftp:x:5006:1002::/var/www/path/to/home:/bin/sh 

Для записи я использовал команду:

useradd scftp -d /path/to/home/dir -g ftpusers 

создавать пользователей. Я не добавил аргумент оболочки, хотя система установила его в / bin / sh.

Я выбрал -Rf / var / www spdftp и chown -Rf / var / www / path / to / home scftp (я хочу, чтобы пользователь spdftp был своего рода главной учетной записью ftp, а scftp имел доступ только к определенной папке сайта). Я также chgrp -Rf / var / www ftpusers

Файл /etc/vsftpd.conf выглядит следующим образом:

# Example config file /etc/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=NO # # Uncomment this to allow local users to log in. local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES   # Ignore shell login request check_shell=NO  # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # Activate logging of uploads/downloads. xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # You may override where the log file goes if you like. The default is shown # below. #xferlog_file=/var/log/vsftpd.log # # If you want, you can have your log file in standard ftpd xferlog format. # Note that the default log file location is /var/log/xferlog in this case. #xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd.banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) chroot_local_user=YES #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd.chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES  pam_service_name=ftp 

Я не уверен насчет последней строки. Я думал, что это должно быть pam_service_name = vsftpd, но ни один не работал в любом случае.

Я также создал vsftpd.chroot_list. Вот содержимое этого файла:

spdftp scftp 

Существует файл /etc/vsftpd.passwd, но в нем нет записей для этих двух имен пользователей. Я не знаю, как создать или добавить их к этому, если это проблема.

Любая помощь будет принята с благодарностью. У меня очень мало волос, и то, что осталось, я вырываю!

ОБНОВИТЬ

Я изменил оболочку каждого пользователя на первый, / bin / false и второй, / bin / bash. Это, по крайней мере, позволило мне войти в систему, не получив 530 Неправильная ошибка входа. Я получаю ошибку тайм-аута сети после этого и следующего в журнале (xxxx - мой фиксированный IP-адрес):

Mon Feb 18 11:49:15 2013 [pid 2] CONNECT: Client "x.x.x.x" Mon Feb 18 11:49:15 2013 [pid 1] [scftp] OK LOGIN: Client "x.x.x.x" Mon Feb 18 11:50:48 2013 [pid 2] CONNECT: Client "x.x.x.x" Mon Feb 18 11:50:49 2013 [pid 1] [spdftp] OK LOGIN: Client "x.x.x.x" 

Похоже, что в /var/log/vsftpd.log нет причин сбоя. Не уверен, что есть другой журнал, который я могу проверить.

ОБНОВЛЕНИЕ 2

Я обнаружил, что оставил пару строк в файле vsftpd.conf:

#guest_enable=YES #guest_username=ftp  #user_config_dir=/etc/vsftpd/vusers 

Как я начал идти по пути создания виртуальных пользователей. Я думал, что прокомментировал это, но я не сделал.

Теперь я могу подключиться, моя последняя проблема в том, что я вернулся с того места, с которого начал, что мои пользователи не могут загружать файлы на сервер. Следующая ошибка в моем vsftpd.log:

Mon Feb 18 12:13:54 2013 [pid 3] [spdftp] FAIL CHMOD: Client "x.x.x.x", "/path/to/home/folder/2013/humans.txt 777" 

Итак, полный круг к тому же вопросу. Кто-нибудь что-нибудь?

0

1 ответ на вопрос

0
tadywankenobi

For what it's worth, I resolved this issue by doing a full purge of the vsftpd service and installation and then re-install. Somewhere along the lines my settings in vsftpd must have gotten crossed wires or conflicts. I had uninstalled before, but did not know about:

aptitude purge vsftpd aptitude autoclean 

Once I did that and then did an

aptitude install vsftpd 

The only setting I needed to change in the vsftpd.conf was write_enable=YES. (I also added a couple of settings to ensure users could not navigate out of their homefolder).

Похожие вопросы