Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Ubuntu 10.10 server running in VirtualBox with OpenSSH installed. I have forwarded port 8888 on the host to 80 on the guest, and 2222 on the host to 22 on the guest. For some reason, I can SSH into this server using localhost:2222 just fine, but when I try to SFTP in with WinSCP also at localhost:2222 I get a "connection refused" error. This is my sshd_config file, if that helps:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

Update: Out of curiosity, I installed FileZilla and tried connecting with that. It worked perfectly fine. Apparently the problem is on WinSCP's end, not the server. I'll look into it some more.

share|improve this question
    
On the Ubuntu server can you do sftp localhost? –  Jason Axelson Apr 5 '11 at 18:55
    
Yeah, that works perfectly fine. I tried starting from scratch with a TurnKey linux OVF file, thinking that'd work out of the box, but WinSCP still isn't connecting. –  Omega192 Apr 6 '11 at 2:42

7 Answers 7

I don't think sftp lets you tack :port to the end of a hostname. You might try

sftp -o Port=2222 localhost

instead

share|improve this answer
    
Indeed the :port syntax actually refers to a file or directory for sftp. Also, "sftp -P 2222 localhost" would be easier than the long options with -o. –  Jason Axelson Apr 5 '11 at 0:07
    
Oop, perhaps I didn't make it clear enough. I'm using WinSCP, so there's no sytax really. Just entering "localhost" into hostname, and 2222 for port. –  Omega192 Apr 5 '11 at 5:39
    
@Bostonvaulter On Linux & OS X the sftp man page says "-P sftp_server_path". On the systems I've checked here you have to use "-o Port=...". –  Gerald Combs Apr 5 '11 at 15:43
up vote 1 down vote accepted

Hmm, I'm not sure how to go about this, so I guess I'll answer my own question. I posted an update to the question, but it appears that people missed it.

Out of curiosity, I installed FileZilla and tried connecting with that. It worked perfectly fine. Apparently the problem is on WinSCP's end, not the server.

share|improve this answer
    
Perfectly acceptable: "You can accept your own answer to a question. There is no reputation awarded and the answer does not float to the top of the list. This can be done no earlier than 48 hours after the question is asked." It is much better to self-answer/accept, if the issue is solved, than to just leave the question open. –  jscott Jun 9 '11 at 18:53

The following works for me: psftp.exe localhost -P 2222 this is assuming port forwarding is guest 2222 for host 22

share|improve this answer

Why do you try connecting with SFTP? Do you have a running FTP-Server? I assume not because you didn't mention it.

Try SCP instead. That should work. Your problem may be related to active/passive FTP modes.

share|improve this answer
    
SFTP != FTPS. –  EEAA Apr 4 '11 at 22:07
    
Yargs.. Should go to bed.. Thanks for correcting me. –  Chris Apr 4 '11 at 22:08
    
Haha, common mistake, it's alright. Thanks anyway! –  Omega192 Apr 4 '11 at 22:32

Check your IPS/IPS for blocking openssh-challenge-response-bo.

share|improve this answer
    
Did you note that connection works with FileZilla? –  Adrian Lang Nov 23 '12 at 11:33

SSHD has a FTP built-in protocol via SFTP that doesn't require a FTP server be running on the server machine. A SCP client or maybe Bitvise Tunnelier should get you connected to transfer files.

share|improve this answer

Some SFTP/SCP clients get very confused if the shell they use on the remote side belches banner messages at them on login, especially if there are terminal escapes etc involved.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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