Can't use ftp

Hello,
I’m trying to connect via ftp to alvarius.mydiscussion.net using this command:

ftp 185.27.134.11

I succeed in connecting as shown by the following log:

Connected to 185.27.134.11.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 478 of 6900 allowed.
220-Local time is now 07:19. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 60 seconds of inactivity.
331 User if0_39289322 OK. Password required
230-Your bandwidth usage is restricted
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.

I can change directory:

ftp> cd alvarius.mydiscussion.net/htdocs/htdocs/
250 OK. Current directory is /alvarius.mydiscussion.net/htdocs/htdocs
ftp> cd 2025
250 OK. Current directory is /alvarius.mydiscussion.net/htdocs/htdocs/2025

but after this I can’t upload any files:

ftp> put public_html/alvarius/htdocs/2025/250625.html 
500 I won't open a connection to 10.18.166.107 (only to 93.37.55.126)
500 Unknown command
ftp>

ps: I also checked specific ftp help that says that put is available even if is not recognized by your system:

ftp> ?
Commands may be abbreviated.  Commands are:
!               dir             macdef          proxy           site
$               disconnect      mdelete         sendport        size
account         epsv4           mdir            put             status
append          form            mget            pwd             struct
ascii           get             mkdir           quit            system
bell            glob            mls             quote           sunique
binary          hash            mode            recv            tenex
bye             help            modtime         reget           trace
case            idle            mput            rstatus         type
cd              image           newer           rhelp           user
cdup            ipany           nmap            rename          umask
chmod           ipv4            nlist           reset           verbose
close           ipv6            ntrans          restart         ?
cr              lcd             open            rmdir
delete          lpwd            passive         runique
debug           ls              prompt          send
ftp> ? put
put             send one file

thanks for any help.

This is not valid

image

You are better off using Filezilla

5 Likes

This is because you are behind NAT. The server received the connection from your home IP address 93.37.55.126, so it will only accept transfers to that IP address. But your computer’s IP address is 10.18.166.107 (the internal IP address on your network), so it tells the server to send the data to that IP address. But that’s not the IP address the server has a connection to.

Fortunately, FTP has a mechanism for this, called Passive FTP.

A quick search tells me that you should be able to setup a passive FTP connection by connecting like so: ftp -p 185.27.134.11.

That said, FTP is not like SSH, it’s not exactly used for arbitrary commands, and I personally wouldn’t recommend using it for manual file administration. FileZilla is a great option, but if you prefer a command line alternative, I would use Rclone for that.

6 Likes

Thanks for your answer.
I found here and, in a more disguised way at least to me, here, that the put command I am using is actually valid but will try to copy the 250625.html file in remote public_html/alvarius/htdocs/2025/ subdir of remote pwd.
What I want to obtain can be achieved with a command like:
put public_html/alvarius/htdocs/2025/250625.html 250625.html
that will copy the obnoxious 250625.html file in remote pwd.
Not sure being so clear though.
I’ll have to review my script as I would like to use a script in bash without using gui clients.

Thanks for your answer.
Passive mode effectively solved half of my problem, the other half being solved by KangJL’s answer.
Now: How can I click solution on both of you :smiley:?

2 Likes

I don’t think there’s a way to mark two replies as the solution at the same time at the moment…

Some might go ahead and post the full solution themselves and mark that as the solution.

3 Likes

Huh, thanks!
I knew that dumbelot was not a senseless pun…

Turned out my problem was a double-leaf one and both Admin and KangJl are to be awarded for solving my problem.
Admin solved the part relative to the error 500 I won't open a connection to 10.18.166.107 (only to 93.37.55.126), which turned to be solvable using the -p flag [passive mode].
KangJL helped me solve the part relative to the put public_html/alvarius/htdocs/2025/250625.html error, that turned to be solved by adding the remote path to the put command like this: put public_html/alvarius/htdocs/2025/250625.html 2025/250625.html.
Oh, and Frank419 for suggesting me to write the solution in a dedicated post.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.