I'm trying to set up a secure ftp transfer between my linux machine and my internet gateway running ubuntu 8.04.

I have vsftpd installed but I can't get PASV connection to work with putty. My ubuntu firewall blocks everything except ssh.

From my windows XP machine I establish a connection with putty to my ubuntu machine. I have putty forward local port 21(windows machine) to 127.0.0.1:21(ubuntu machine).

This works sort of. I use the ftp client from windows command line to connect to 127.0.0.1 21, which forwards me to port 21 on the ubuntu machine and allows me to connect/login.

Then after I enter "quote PASV" and try a "dir" command it hangs. In vsftpd.conf I had added lines pasv_max_port=21 and pasv_min_port=21 so that the ftp server would tell the windows ftp client to use port 21 for data transfers.

I then added "pasv_address=127.0.0.1" to vsftpd.conf, thinking vsftp was telling the windows ftp client to try and connect to something other than localhost, and vsftpd wouldn't start, it said I had to edit 2 files.

I already have sftp working with psftp.exe, but I'd like one entry point into my system and psftp doesn't load bash.bashrc, so I want ftp through ssh to work.

See this site for PASV ftp: http://www.slacksite.com/other/ftp.html

Dani AI

Generated

— the control channel (port 21) is being forwarded over SSH, but passive FTP opens a separate data connection to whatever IP:port the server advertises. Forwarding only port 21 will never carry those PASV data connections, and if the PASV range is invalid vsftpd will fall back to ephemeral ports (which is why Wireshark showed high-numbered ports).

Corrective steps:

  • Ensure the passive range is valid (min < max) and pick a contiguous high port range. For example:
    pasv_min_port=55000
    pasv_max_port=55100
  • Open that entire range in iptables/ufw and, if the server is behind NAT, forward the same range on the router to the FTP host.
  • Set pasv_address to the IP/hostname that clients actually connect to (the public IP for internet clients; 127.0.0.1 only if the client is truly connecting to the local loop via SSH forwarding). Use pasv_addr_resolve=YES if a hostname is used. connect_from_port_20 only affects active mode, not passive.

Options and workarounds:

  • Tunnel the whole PASV range over SSH (multiple forwarded ports in PuTTY) or use dynamic (SOCKS) forwarding and an FTP client that supports SOCKS/proxies (Windows ftp.exe does not).
  • Prefer SFTP (the SSH File Transfer Protocol) when using SSH: it avoids PASV/active issues entirely and uses the single SSH connection (psftp/WinSCP/ FileZilla SFTP).

Quick troubleshooting checklist:

  • Confirm vsftpd started cleanly and check logs (syslog/vsftpd) for errors.
  • Use netstat -lntp or ss -lntp to see which ports vsftpd is listening on and run a packet capture to verify the server-advertised PASV port.
  • If the PASV port seen on the wire is outside the intended range, recheck the min/max ordering and restart vsftpd.

— PuTTY is fine for SSH; the FTP PASV behavior is independent of PuTTY itself.

Recommended Answers

All 2 Replies

Ok I decided to ditch the port forwarding and just get it working normally first. I got it working by opening my local interface through iptables.

In vsftpd.conf I specified a port range of 55000 to 55100 for PASV ports, but vsftpd doesn't use that range.

Using wireshark I captured ftp packets and saw vsftpd sent PASV ports 62237 and 58847 for two different ftp sessions.

Why is it not using the specified range?


Here is a non-commented copy of vsftpd.conf.

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
pasv_max_port=55000
pasv_min_port=55100
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
log_ftp_protocol=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

I use putty in my school's laboratory.
But I don't know you how to use vsftp?
Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.