18

How do I check which FTP (Passive or Active) is running?

By default, passive FTP is running in linux, but how do I check?

Anthon
  • 78,313
  • 42
  • 165
  • 222
Rahul Patil
  • 24,281
  • 25
  • 80
  • 96

2 Answers2

19

I found the answer as below.

in passive mode we can run ls command but in active mode we have to manually disable passive mode by typing passive command then it will accept ls command otherwise it's gives 550 permission denied error . see below (pasv_enable=NO in vsftpd.conf)

ftp> passive
Passive mode on.
ftp> ls
550 Permission denied.
Passive mode refused.
ftp> passive
Passive mode off.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-rw-r--    1 503      503             0 Jan 11  2013 files1
-rw-rw-r--    1 503      503             0 Jan 11  2013 files10
-rw-rw-r--    1 503      503             0 Jan 11  2013 files2
-rw-rw-r--    1 503      503             0 Jan 11  2013 files3
-rw-rw-r--    1 503      503             0 Jan 11  2013 files4
-rw-rw-r--    1 503      503             0 Jan 11  2013 files5
-rw-rw-r--    1 503      503             0 Jan 11  2013 files6
-rw-rw-r--    1 503      503             0 Jan 11  2013 files7
-rw-rw-r--    1 503      503             0 Jan 11  2013 files8
-rw-rw-r--    1 503      503             0 Jan 11  2013 files9
-rw-r--r--    1 0        0           10240 Jan 11  2013 test.tar
226 Directory send OK.
ftp>

ls listing that we asked for on the server comes back over the port 20 on the server to a high port connection on the client. No use of port 21 on the server is made to send back the results of the ls command on the server.

above is extracted from "http://www.markus-gattol.name/ws/vsftpd.html"

mwfearnley
  • 1,104
  • 1
  • 16
  • 19
Rahul Patil
  • 24,281
  • 25
  • 80
  • 96
  • Agree, `passive` with `ls` within the client is an easy way to check. Actually, if we can send "PASV" to the server, the server will reply the answer. But I can't find the command within ftp client to do it. – John Siu Dec 19 '12 at 05:35
8

From ftp client, to check if remote ftp server support passive mode, after login, type quote PASV.

Following are connection examples to a vsftpd server with passive mode on and off

vsftpd with pasv_enable=NO

# ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.3.5)
Name (localhost:john): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quote PASV
550 Permission denied.
ftp> 

vsftpd with pasv_enable=YES

# ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.3.5)
Name (localhost:john): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quote PASV
227 Entering Passive Mode (127,0,0,1,173,104).
ftp> 

The ftp command quote send all arguments following it to remote server. Remote server will process them as command/request if applicable. PASV is a request for server to use passive mode.

John Siu
  • 4,695
  • 2
  • 25
  • 22
  • even "pasv_enable=NO" in vsftpd.conf , the passive command says passive mode on. – Rahul Patil Dec 19 '12 at 04:46
  • Did you test it behind a nat router? If you can download file, then it is actually on. Another way is force your ftp client to use passive mode only and test it. – John Siu Dec 19 '12 at 04:52
  • Hi John, Please check above post and let me know if i am wrong – Rahul Patil Dec 19 '12 at 05:16
  • @RahulPatil yes, you are correct. My original answer only set passive mode on *client* side. I revised my answer with the correct way. You info / method is also correct. – John Siu Dec 19 '12 at 15:16