我可以使用端口 22 连接到我的 ftp 服务器。但我认为端口 21 未激活。:
错误:20 秒不活动后连接超时 错误:无法连接到服务器
UFW 状态
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
20/tcp ALLOW Anywhere
21/tcp ALLOW Anywhere
990/tcp ALLOW Anywhere
40000:50000/tcp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
20/tcp (v6) ALLOW Anywhere (v6)
21/tcp (v6) ALLOW Anywhere (v6)
990/tcp (v6) ALLOW Anywhere (v6)
40000:50000/tcp (v6) ALLOW Anywhere (v6)
我的 vsftpd.config:
listen=YES
listen_ipv6=YES
local_enable=YES
write_enable=NO
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO
ssl_ciphers=HIGH
user_sub_token=$USER local_root=/home/$USER/ftp
pasv_min_port=40000 pasv_max_port=50000
userlist_enable=YES userlist_file=/etc/vsftpd.userlist userlist_deny=NO
#netstat -lntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
udp 0 0 127.0.0.53:53 0.0.0.0:*
网络统计的输出:
#netstat -pant | grep 21
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 299540/vsftpd
tcp 0 0 ****:22 *****:52150 ESTABLISHED 299854/sshd: unknow
vsftpd 的状态:
# systemctl status vsftpd
● vsftpd.service - vsftpd FTP server
Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-03-30 13:27:34 UTC; 53s ago
Process: 299078 ExecStartPre=/bin/mkdir -p /var/run/vsftpd/empty (code=exited, status=0/SUCCESS)
Main PID: 299082 (vsftpd)
Tasks: 1 (limit: 4575)
Memory: 916.0K
CGroup: /system.slice/vsftpd.service
└─299082 /usr/sbin/vsftpd /etc/vsftpd.conf
答案1
有一个选项叫做监听端口你可以在 vsftpd.config 文件中设置它,例如:
listen_port=21