Acesso do ftp do usuário do Ubuntu

0

Tendo problemas reais com acesso ftp à minha solução ubuntu cloud VPS.

Eu tentei o vsftpd e o pure-ftpd. Eu achei que ambos eram limitados. Agora tentei me concentrar no vsftpd, pois é bem recebido.

Eu tentei seguir as instruções aqui:

link

A única coisa que eu não tenho feito neste guia até agora é adicionar as regras TLS / SSL / FTPS, pois estou tendo problemas para adicionar a porta 990 às configurações do firewall do servidor. Isso foi sinalizado com meu provedor e espero que seja resolvido a tempo.

Inicialmente, eu estava usando usuários que tinham acesso ao shell. Isso permitia ao usuário fazer login e acessar o servidor e as pastas corretas, mas não podia gravar novos arquivos ou substituir os arquivos existentes no servidor. Eles poderiam criar pastas e excluir arquivos. Quando eu entrei com contas shell usando linha de comando ftp, eu poderia escrever (mput) arquivos para o servidor sem problemas, mas eu espero que isso se deva ao modo como a linha de comando ftp funciona em oposição a um serviço ftp.

Eu pensei que meu problema poderia ser que meus usuários não pudessem acessar como tinham acesso ao shell. Eu criei um novo usuário sem acesso ao shell. Não consigo fazer login com esses usuários. Estou recebendo um 530 Login incorreto, embora eu tenha mudado e testado a senha. Eu não consigo logar com a linha de comando ftp.

Eu incluí abaixo do meu arquivo vsftpd.conf. Eu tentei um personalizado, mas acabou revertendo para o original, só para começar de novo. Eu adicionei a diretiva check_shell = NO para ver se isso ajudou. Eu tinha começado o caminho de adicionar usuários virtuais ao sistema, mas não vejo como isso vai mudar nada.

Eu literalmente passei o fim de semana inteiro tentando resolver isso, sem sucesso.

Aqui estão os conteúdos / etc / shadow (com pwds com hash). Os dois novos usuários são spdftp e 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:::

Aqui está a saída do arquivo / etc / passwd para esses usuários:

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

Para o registro, usei o comando:

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

para criar os usuários. Eu não adicionei um argumento shell, embora o sistema tenha configurado para / bin / sh.

Eu chown -Rf / var / www spdftp e chown -Rf / var / www / caminho / para / home scftp (Eu quero que o usuário spdftp como um tipo de conta master ftp e scftp para ter acesso somente a um site específico pasta). Eu também chgrp -Rf / var / www ftpusers

O arquivo /etc/vsftpd.conf é o seguinte:

# 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

Não tenho certeza sobre a última linha. Eu pensei que deveria ser pam_service_name = vsftpd mas nem funcionou de qualquer maneira.

Eu também criei o vsftpd.chroot_list. Aqui está o conteúdo desse arquivo:

spdftp
scftp

Existe um arquivo /etc/vsftpd.passwd, mas não possui entradas para esses dois nomes de usuário. Eu não sei como criar ou adicioná-los a isso, se este for o problema.

Qualquer ajuda seria muito apreciada. Eu tenho muito pouco cabelo e o que sobrou eu estou arrancando!

UPDATE

Eu mudei o shell de cada usuário para primeiro, / bin / false e segundo, / bin / bash. Isso pelo menos me permitiu entrar, sem receber o 530 Erro de login incorreto. Eu recebo um erro de tempo limite da rede depois disso e do seguinte no log (x.x.x.x é o meu endereço IP fixo):

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"

Parece não haver nenhum motivo de falha no /var/log/vsftpd.log. Não tenho certeza se há outro log que eu possa verificar.

UPDATE 2

Descobri que deixei algumas linhas no arquivo vsftpd.conf:

#guest_enable=YES
#guest_username=ftp

#user_config_dir=/etc/vsftpd/vusers

Como eu comecei o caminho da criação de usuários virtuais. Eu pensei que tinha comentado isso, mas eu não tinha feito isso.

Agora posso me conectar, meu último problema é que estou de volta onde comecei, pois meus usuários não podem enviar arquivos para o servidor. O seguinte erro está no meu 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"

Então, complete o círculo para o mesmo problema. Alguém tem alguma coisa?

    
por tadywankenobi 18.02.2013 / 12:14

1 resposta

0

Por que vale a pena, resolvi esse problema fazendo uma limpeza completa do serviço vsftpd e da instalação e, em seguida, reinstalei. Em algum lugar ao longo das linhas, minhas configurações no vsftpd devem ter cruzamentos ou conflitos. Eu tinha desinstalado antes, mas não sabia sobre:

aptitude purge vsftpd
aptitude autoclean

Uma vez eu fiz isso e então fiz um

aptitude install vsftpd

A única configuração que eu precisava mudar no vsftpd.conf era write_enable = YES. (Eu também adicionei algumas configurações para garantir que os usuários não pudessem navegar em sua homefolder).

    
por 18.02.2013 / 16:42