Score:0

ftp Connection refused over virtualbox

hm flag

I am running Ubuntu 22.04 (Computer A) as a host and Ubuntu 20.04 inside a virtualbox (Computer B). I want to be able to ftp from the host to the VB, but I get connection refused whenever I try to ftp or ssh.

I set up an ftp server using vsftpd using instructions online. I can manage to ftp into computer B from itself using ftp localhost, so I think the server is setup properly.

run@write:/etc$ ftp localhost
Connected to localhost.
220 (vsFTPd 3.0.3)
Name (localhost:run): run
331 Please specify the password.
Password:
230 Login successful.

I have setup the firewall to listen on the relevant ports

run@write:/etc$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
21/tcp                     ALLOW       Anywhere                  
20/tcp                     ALLOW       Anywhere                  
990/tcp                    ALLOW       Anywhere                  
40000:50000/tcp            ALLOW       Anywhere                  
OpenSSH                    ALLOW       Anywhere                                 
21/tcp (v6)                ALLOW       Anywhere (v6)             
20/tcp (v6)                ALLOW       Anywhere (v6)             
990/tcp (v6)               ALLOW       Anywhere (v6)             
40000:50000/tcp (v6)       ALLOW       Anywhere (v6)             
OpenSSH (v6)               ALLOW       Anywhere (v6)                 

ipconfig on computer B showed that the IP address was 10.0.2.15 so I set up port-forwarding in the networking settings in VB.

Port Forwarding List

But when I try to ftp into B from A I get connection refused using ftp. I don't even get to asking for username and password.

I tried to telnet to localhost and the port number but got connection refused. I used nmap to see which ports were open, but none of the ones specified in ufw are open and two other ones are open so I'm wondering where the breakdown is happening.

nmap localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2022-11-21 23:04 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000028s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
631/tcp  open  ipp
5500/tcp open  hotline

Is the issue with how I set up the virtual box or how I'm trying to ftp to the virtual box?

Terrance avatar
id flag
Sometimes it might be easier to set the NIC in Virtualbox to Bridged instead of NAT. The bridging can be a pain to get working correctly. I have not had much time to mess with the new Virtualbox 7 though either. I had an issue with it where the Extension Pack would reboot all my hosts I had in VB when I would try to Insert the Extension Pack. Virtualbox 6.1 is still working great for what I need.
Terrance avatar
id flag
I meant NAT can be a pain, not Bridging. Sorry, long day. :)
ThomasK avatar
hm flag
I tried with both NAT and Bridged adaptor but with no sucess
Terrance avatar
id flag
When you setup the SSH server, did you install `openssh-server` as well as create a new key using `sudo ssh-keygen` to allow for ssh connections? Also, `nmap` should be ran on the IP address and not `localhost` as they will return different ports open. But, I am not seeing that SSH even opened the ports as 21 goes for FTP and 22 is for SSH by default.
Score:0
hm flag

I managed to figure out what is happening maybe.

I started by turning off the firewall

sudo ufw disable

Then I changed the port I was using for ftp to 2121 and set up the port forwarding to send 2121 to 21 inside the virtual box.

After this everything worked as expected. I don't know if computer A reserved 21 for itself in some way, but this solution worked for me

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.