0

I'm sorry as I imagine different versions of this question have come up often but I can't seem to resolve my issue through others' posts.

I am trying to learn about other OSes for work, and my work uses Redhat Linux so I am trying to follow a guide to setup my own CentOS 7 server. I am running CentOS 7 and Ubuntu on VMs both through VirtualBox. I am running the traffic for the CentOS 7 server through port 2222.

I am able to connect via SSH from my Ubuntu Server with the command ssh -p 2222 user@[host computer's IP]. I am even able to connect to my CentOS from my Windows Host Terminal with ssh -p 2222 user@localhost. "User" is the actual username I'm trying to access and it connects. I've even setup an authentication key for both but when I try to swap the command to SFTP, it will give me a "Connection refused" or "Timed Out" then "Connection closed".

I've tried commands like sftp -p 2222 user@[host ip], I've tried adding the port to the end of the IP with :2222. I've tried root@ip and root@localhost. I've tried updating my sshd_config but I don't think I understand it well enough to be certain the settings are all correct.

I've also tried to create a connection with some of the above information with FileZilla, to get this error:

Status: Connecting to 127.0.0.1:2222...
Status: Connection established, waiting for welcome message...
Response:   SSH-2.0-OpenSSH_7.4
Error:  Cannot establish FTP connection to an SFTP server. Please select proper protocol.
Error:  Critical error: Could not connect to server

I need to get a ZIP file onto my CentOS server and I cannot get this figured out. I would appreciate any guidance.

1
  • Note that the port in sftp is specified with the option -P while in ssh it is -p. I don't know if it is a typo in your question, or if you are trying to use sftp -p 2222... (The -p option on sftp is for preserving timestamps and mode.) Apr 7, 2023 at 22:34

1 Answer 1

2

I've got it working with these settings on CentOS VM NIC:

settings

  • 192.168.1.222 is the Host IP
  • 10.0.2.15 is CentOS Guest

With these settings I can both SSH and FTP in using the Host IP and port 2222:

ssh [email protected] -p 2222
sftp -P 2222 [email protected]

Also SCP works. This command transfers file foo in my Documents -directory to the VM, user's Documents -directory:

scp -P 2222 ~/Documents/foo <user>@192.168.1.222:/home/<user>/Documents

I tested this successfully from the host, 3 NATted VMs running on the same host (Deb 11, Deb 12 and Ubu 22.04 LTS). I also confirmed it works with FileZilla client. I used a vanilla CentOS 7 installation straight out of the box. I didn't even update it yet, let alone change any settings.

Note that I've set the NATted VM IPs manually (10.0.2.16, .17 etc...). They get by default the same IP .2.15; and multiple systems with the same IPs make my teeth ache...

2
  • Thank you very much for continuing to look into it. I think there was an underlying issue with my network config as I'm still learning a lot. I ended up deleting the original server and trying again on an old laptop to simplify the networking aspect. However, with seeing your success, I tried again with virtualbox and was able to successfully connect via sftp. It's possible I just didn't quite have the right command for it initially or had gotten confused in my first runthrough and messed up the config. Either way, I appreciate you taking the time to follow up and provide a thorough answer Apr 9, 2023 at 3:46
  • De nada! Thank yourself, I finally got around to looking into RH-systems for the first time in a decade and a half :-) If the answer helped, please do accept it to close the question. Apr 9, 2023 at 5:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .