I have Centos running a Linux VM on a Windows machine. I'm not able to connect to the VM using WinSCP with sftp on port 22 or ftp on port 21. I have

Subsystem  sftp    /usr/libexec/openssh/sftp-server

in /etc/ssh/sshd_config. I've executed

/etc/init.d/sshd start

I have openssh-server installed in /usr/libexec/openssh. When I try to connect using WinSCP the message I get says "The server rejected SFTP connection, but it listens for FTP connections." Then when I switch to port 21 and try to connect the message says "Disconnected from server Connection failed." I have the vm running and the ip address I'm trying to connect to matches the inet address I get when I run ifconfig

  • you need to add some more detail about networking used between host and guest. For example, if using a NAT'ed interface, you'll have to set some port redirection in order to achieve this. – tonioc Nov 23 '17 at 12:22

Try ps aux | grep sshd on the remote server. This will tell you whether the SSH daemon is started.

If not, you have to look at the log to see why it did not start and correct the configuration file.

If yes, you have to figure out on which port is is listening netstat -ntapl and use it in WinSCP.

If it is still not working even by using the right port, you may have an issue with your credentials.

  • I see it running when executing ps aux | grep sshd executing the next command I see sshd on, I switched to port 25 in WinSCP and it says "Server unexpectedly closed network connection" – gary69 Jul 15 '15 at 16:03
  • You need to listen on (ListenAdress in your sshd config file). – user123418 Jul 15 '15 at 17:25
  • In my sshd_config file I uncommented #ListenAddress and was still unable to connect on ports 21, 22, and 25. I then uncommented #Port 22 two lines above the listen address and was unable to connect on port 22 or any ports in WinSCP. It says "The server rejected SFTP connection, but it listens for FTP connections." when I try to connect on port 22, "Server unexpectedly closed network connection when I try to connect on port 25", and "Disconnected from server" on port 21. Running netstat -ntapl now that I've uncommented shows: tcp 0 0 – gary69 Jul 15 '15 at 20:50
  • There is another #ListenAddress line beneath the ListenAddress I uncommented that says #ListenAddress :: – gary69 Jul 15 '15 at 20:52
  • Actually it says in the file that the commented values are the default values – gary69 Jul 15 '15 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.