HostOnNet Blog

lftp using active mode for file transfer

Looking for Linux Server Admin or WordPress Expert? We can help.

By default lftp and ftp use Passive Mode. I had to FTP a file from a server to remote server. Due to firewall settings, i was not able to upload file as FTP session get stuck on

flashwebhost@pc5:~ $ ftp
ftp> open windowware.hostonnet.com
Connected to hostonnet.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 12:20. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (windowware.hostonnet.com:flashwebhost): windowcoveringde
331 User windowcoveringde OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful
150 Connecting to port 35694

This is because remote server have not opened ports required for Passive FTP.

To solve, you can open port on remote server or white list IP on remote server. Another solution is to use Active Mode FTP.

To enable active mode FTP in lftp, run

set ftp:passive-mode off

Here is an example

root@server2 [/home]# lftp -u windowcoveringde server10.hostonnet.com
Password: 
lftp [email protected]:~> set ftp:passive-mode off
lftp [email protected]:~> dir
drwx--x--x   17 windowcove windowcove       4096 Nov 12 14:09 .
drwx--x--x   17 windowcove windowcove       4096 Nov 12 14:09 ..
-rw-r--r--    1 windowcove windowcove         18 Jul 27 23:45 .bash_logout
-rw-r--r--    1 windowcove windowcove        176 Jul 27 23:45 .bash_profile
-rw-r--r--    1 windowcove windowcove        124 Jul 27 23:45 .bashrc
drwxr-x---    2 windowcove 99               4096 Nov  3 19:10 .htpasswds
-rw-------    1 windowcove windowcove        631 Dec 19 10:37 .lastlogin
-rw-r-----    1 windowcove windowcove          1 Sep 20 04:09 cpbackup-exclude.conf
drwxr-x---    2 windowcove 12               4096 Sep 22 14:51 etc
drwx------    2 windowcove windowcove       4096 Jan  4 14:14 logs
drwxr-x--x    8 windowcove windowcove       4096 Nov 11 23:46 mail
drwxr-xr-x    2 windowcove windowcove       4096 Sep 15 13:10 melbin
drwxr-x---    3 windowcove windowcove       4096 Nov  3 19:10 public_ftp
drwxr-x---   18 windowcove 99               4096 Jan  4 12:14 public_html
drwxr-xr-x    5 windowcove windowcove       4096 Oct 14 01:21 ssl
drwxr-xr-x    7 windowcove windowcove       4096 Dec  7 16:07 tmp
lrwxrwxrwx    1 windowcove windowcove         11 Nov  3 19:10 www -> public_html
lftp [email protected]:/> mkdir backup-new
mkdir ok, `backup-new' created                
lftp [email protected]:/> cd backup-new
cd ok, cwd=/backup-new                     
lftp [email protected]:/backup-new> put cpmove-windowwa.tar.gz
`cpmove-windowwa.tar.gz' at 117438632 (1%) 10.10M/s eta:9m [Sending data]  

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.