因此,为了稍微保护我的服务器,我创建了一个具有 su - root 访问权限的新用户并拒绝 root 登录。现在我无法使用该用户通过 Filezilla 对我的服务器上的任何文件进行 SFTP。这些是我采取的步骤:
/etc/ssh/sshd_config使用Filezilla SFTPPermitRootLogin yes进行编辑PermitRootLogin no。现在,不幸的是,当使用新用户/密码通过 Filezilla 进行 SFTP 时,我可以访问和查看服务器中的所有目录/文件,但无法打开/读取/编辑它们。
我是否需要以 root 用户身份更改权限设置,以便新用户能够执行此操作?我有没有搬起石头砸自己的脚?
编辑:好的,root 被 chmod 了文件 777,这允许我以新用户身份查看/编辑,但是有没有办法简单地向用户授予 SFTP 的所有这些权限,而不是公众/任何人别的?
我有一台机器,它是主机,并且安装了 HAProxy 并且可以工作。然后我有一个来宾 KVM 虚拟机在具有 IP 的主机内运行192.168.122.152。我使用 VSFTPD 在来宾计算机上安装了 FTP 服务器。
从主机上,如果我尝试该命令$ ftp -p 192.168.122.152,工作正常,并且我可以连接到来宾 FTP。我需要指出的是,此 FTP 配置为被动,但被动和主动连接都可以从主机进行工作。
/etc/vsftpd.conf这是来宾中的部分摘录:
# Passive mode
connect_from_port_20=NO
tcp_wrappers=YES
listen_address=192.168.122.152
pasv_enable=YES
pasv_promiscuous=NO
port_enable=YES
port_promiscuous=NO
pasv_max_port=10000
pasv_min_port=10250
Run Code Online (Sandbox Code Playgroud)
现在是时候让它可以从外部访问了,所以我/etc/haproxy/haproxy.cfg这样配置:
listen FTP_Default *:21
server ftp01 192.168.122.152 check port 21 inter 10s rise 1 fall 2
listen FTP_Range *:10000-10250
server ftp01 192.168.122.152 check port 21 inter 10s rise 1 fall 2
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试从互联网上的其他计算机进行连接$ ftp -p $PUBLICIP,它只会响应:Connected to <PUBLICIP>,但不会要求输入登录名和密码。
HAProxy …
我安装了vsftpd,在本地访问时一切正常,但远程访问时无法查看文件夹。
在我的远程 PC 上使用 filezilla,我得到了这个:
status: connecting to 192.x.x.x
status: connection established, waiting for welcome message
response: welcome
command: user admin
response: specify pass
command: pass ****
response: 230 login successful
command: opts utf8 on
response: 200 always in utf8 mode
status: connected
status: retrieving directory listing..
command: pwd
response: 257 "/var/ftp"
command: type I
response: 200 switching to binary mode
command: PASV
response: 227 entering passive mode (192.168.8.5,59,0).
command: list
Run Code Online (Sandbox Code Playgroud)
它就停在那里,然后连接超时,我无法查看 ftp 服务器上的文件夹或目录。
在我的 iptables -L -n …
在远程 FTP 服务器上,我在目录中有一组文件remote.dir1。我想将该目录中的所有文件移动到remote.dir2.
我正在使用lftp并正在尝试这样的事情:
lftp> mv remote.dir1/* remote.dir2/
Run Code Online (Sandbox Code Playgroud)
它不起作用并显示: Access failed: 550 remote.dir1/*: The filename, directory name, or volume label syntax is incorrect.
我也试过:
lftp> glob -a mv remote.dir1/* remote.dir2/
Run Code Online (Sandbox Code Playgroud)
显示使用信息: Usage: mv <file1> <file2>
但是,移动单个文件有效: lftp> mv remote.dir1/file1 remote.dir2/
作为最后的手段,我们可以构建一个包含一组 lftpmv命令和source它的文件。
有没有我不知道的解决方案?
或者,是否有任何功能强大的命令行工具来完成这项任务?
编辑:我仅限于 FTP 环境,因此由于环境限制,只能接受使用 FTP 的解决方案。
我在 AWS 上运行服务器,并连接到合作伙伴的 FTP 站点(不太了解他们在运行什么)。我的服务器有一个弹性 IP。在下面的结果中 xx.xx.xx.xx 是内部 IP(与我从 IPConfig 得到的相同)。yy.yy.yy.yy 是外部 IP(与 RDPed 相同)。
Connected to ftp.site.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 22:47. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
User (ftp.site.com:(none)): someuser
331 User someuser OK. Password required
Password:
230 OK. Current restricted directory is /
ftp> literal pasv
227 Entering …Run Code Online (Sandbox Code Playgroud) 使用被动模式时,如果我们将 pasv_max_port 设置为 10100,将 pasv_min_port 设置为 10090。是否意味着 VSFTP 服务器只能同时为 10 个客户端提供服务?
我们可以为 pasv_max_port 和 pasv_min_port 设置相同的端口号吗?如果可能,VSFTP 服务器可以同时处理多少个客户端?只有一个?
设置:
VSFTPD FTP 服务器
只有 FTP 用户可以访问 FTP
用户主页修改为 /var/www
用户现在只能写访问 /var/www
用户仍然可以浏览文件夹结构 -这是我想要防止的。
换句话说,如何防止 FTP 用户浏览 /var/www 上的任何文件夹?
我的 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 …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置对我的 Apache 服务器的 FTP 访问,但我收到一个530 Login Incorrect错误。
我通过sudo apt-get install vsftpd.
我尝试ftp://(my ip address)与我创建的用户连接,该用户andrew属于ftp用户组。我也试过与root. 我确定密码是正确的。
理想情况下,我希望能够连接到我的/var/www/目录以通过 FTP 客户端上传文件。
这是我的vsftpd.conf文件没有注释的样子:
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
Run Code Online (Sandbox Code Playgroud)
并附有评论:
# 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.
# …Run Code Online (Sandbox Code Playgroud) 对不起,如果这对你来说听起来多余,但相信我不是。我已经尝试了几乎大多数与此问题相关的链接,但到目前为止没有任何效果。我什至尝试了这篇文章二。以下是我迄今为止尝试过的
MindTerm home: /home/waqas/.mindterm/
SSH Server/Alias: 54.191.37.141
Connected to server running SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
Server's hostkey (ssh-rsa) fingerprint:
openssh md5: 95:44:f1:40:07:90:00:2a:7d:9a:1f:49:a1:71:8a:0b
bubblebabble: xilon-segen-tufep-manir-rekad-lucag-fetoz-sover-hyhuh-kafiz-kixox
Run Code Online (Sandbox Code Playgroud)
在此问题之前我做的最后一件事是 2 天前我试图使用此链接在我的客户端上安装 FTP 服务器http://www.krizna.com/ubuntu/setup-ftp-server-on-ubuntu-14 -04-vsftpd/ . 不幸的是,这个链接没有按预期工作,我最终没有成功登录 FTP。今天,当我尝试使用我的密钥对登录时,它给了我错误。
以下是我的 ssh 尝试日志
waqas@waqas-itu:~/Downloads/key$ ssh -v -i test.pem ubuntu@54.191.37.141
OpenSSH_6.0p1 Debian-3ubuntu1.2, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: …Run Code Online (Sandbox Code Playgroud) 我刚刚在我的 Windows Server 2012 R2 机器上的 IIS 8.5 中设置了一个 FTP 服务器。
使用 FileZilla 当我尝试使用我的用户名和密码在端口 21 上连接到本地 IP (10.0.0.4) 时,它会连接得很好,但是当我尝试连接外部 IP 时,我收到此错误
服务器发送带有不可路由地址的被动回复。改用服务器地址
这是完整的日志
Status: Disconnected from server
Status: Connecting to 191.23x.xx.111:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Status: Connected
Status: Retrieving directory listing...
Status: Server sent passive reply with unroutable address. Using server address instead.
Command: LIST
Response: 150 Opening BINARY mode data connection.
Error: Connection timed out after …Run Code Online (Sandbox Code Playgroud)