Update: I did the steps recommended by Digital Ocean support (at the bottom) and posted a followup: https://unix.stackexchange.com/questions/179163/how-to-get-sftp-on-ubuntu-working-again-should-i-try-to-fix-it-or-reinstall

For the first time since creating my Digital Ocean server, I am getting a "connection refused" error when trying to connect to my with either SFTP Net Drive (so I can map it as a lettered drive on my Windows machine), WebDrive (and SFTP Net Drive competitor), or FileZilla. I can connect with the console just fine.

I also created a new temp account, which __CAN__ sftp to the same machine just fine.

I've updated and restarted by the server and my Windows machine, and re-installed SFTP Net Drive, but it still fails.

No configuration has changed at all, on either machine. I am an Ubuntu/Bash newbie. I've been playing around with aliases and alias-like functions in my .bashrc (like here, here, here, and here, but nothing I can fathom that would affect this. I haven't changed any other configuration at all. I don't know how to yet.

On SFTP Net Drive Free, here's the main screen:


When I attempt to connect:


According to their website, this means SSH_ERROR_CONNECTION_CLOSED.

Detailed configuration (again, unchanged since August):


On WebDrive it's the same thing: "Winsock Error: WSAECONNREFUSED (10061)". This message is the same for every possible option:


Attempting to connect via FileZilla with non-secure FTP (I changed my real ip to Forgive me if it's not a valid one):

Status: Connecting to
Status: Connection established, waiting for welcome message...
Response: SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
Error: Cannot establish FTP connection to an SFTP server. Please select proper protocol.
Error: Critical error: Could not connect to server

My Setup:


With SFTP:

Status: Connecting to
Response: fzSftp started
Command: open "myusername@" 22
Command: Pass: ************
Status: Connected to
Error: Connection timed out
Error: Could not connect to server

It hangs at the "Connected to" line, and then times out. It never actually connects.

Using FTP with "Require explicit FTP over TLS":

Status: Connecting to
Status: Connection attempt failed with "ECONNREFUSED - Connection refused by server".
Error: Could not connect to server

Same result with "implicit"

$ ping

Pinging with 32 bytes of data:
Reply from bytes=32 time=21ms TTL=251
Reply from bytes=32 time=24ms TTL=251
Reply from bytes=32 time=26ms TTL=251
Reply from bytes=32 time=17ms TTL=251

Ping statistics for
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 17ms, Maximum = 26ms, Average = 22ms

$ tracert

Tracing route to originaldjangster.com []
over a maximum of 30 hops:

1 <1 ms <1 ms <1 ms Wireless_Broadband_Router.home []
2 7 ms 7 ms 8 ms L100.CMDNNJ-VFTTP-20.verizon-gni.net []
3 12 ms 11 ms 14 ms G0-1-3-2.CMDNNJ-LCR-22.verizon-gni.net []
4 33 ms 12 ms 16 ms xe-9-1-2-0.NY5030-BB-RTR2.verizon-gni.net []
5 * * * Request timed out.
6 12 ms 16 ms 17 ms 2.ae0.XT2.NYC4.ALTER.NET []
7 23 ms 20 ms 24 ms TenGigE-7-0-3.GW5.NYC4.ALTER.NET []
8 12 ms 17 ms 15 ms teliasonera-gw.customer.alter.net []
9 14 ms 17 ms 18 ms nyk-b6-link.telia.net []
10 16 ms 16 ms 17 ms digitalocean-ic-306491-nyk-b5.c.telia.net []
11 20 ms 20 ms 11 ms
12 26 ms 16 ms 17 ms originaldjangster.com []

After talking with Digital Ocean, they say they can't replicate anything, and they're not allowed to login directly with a temp account I've created for temp (nor my actual account with a temp password). They've suggested I try these (in their words, "very dated") steps.

I will, and I will update this question with the results. But I'm exhausted and I need to pick up my kid from school.

Any clues in what I've written so far? I am completly stuck, and everything I need to do is via SFTP.

Here's the full support thread with Digital Ocean.

I was told that SFTP was "beatiful or a nightmare". Now I guess I understand.

  • Have you tried some other SFTP client to rule out some entirely whacky reason which I cannot actually think of. – Ramhound Jan 14 '15 at 19:19
  • @Ramhound Yes. WebDrive. It's below the SFTP Net Drive "in depth" config screenshot. – aliteralmind Jan 14 '15 at 19:32
  • 1
    It seems that, since the new "temp" account can SFTP just fine, that it's an Ubuntu configuration issue. Can't imagine what... – aliteralmind Jan 14 '15 at 19:34
  • I missed that. This doesn't help you exactly, but we will need to find a better title for this question :-) – Ramhound Jan 14 '15 at 19:44
  • @Ramhound What, not long enough? ;) – aliteralmind Jan 14 '15 at 19:48

I read through the thread and you have a mix of FTP, FTP/S, and SFTP examples all trying to connect to the same server on the same port. It's important to keep in mind that SFTP, FTP/S, and FTP are all very different, and run on different ports.

SFTP (Secure File Transfer Protocol over SSH encryption) runs on port 22 usually and is not the same as FTP/S. FTP/S (File Transfer Protocol (RFC959) over SSL/TLS encryption) typically runs on port 990 or port 21 (if using AUTH SSL/TLS).

If your server is SFTP, then you want to configure your SFTP client, we like WebDrive :), in SFTP mode. Once you have the protocol set up, verify that your username and password are correct.

If you don't get that far, or if you get a Handshake Failure, it's possible that the client and server cannot negotiate a common set of Ciphers & Macs. There has been a trend recently to move away from CBC based ciphers and move over to more secure CTR based ciphers. If your SFTP client is configured to use only AES+CBC it's possible that the server no longer accepts those and you'll need to update your SFTP client to use any CTR ciphers instead....check with your server Admin to see what they support.

WRT WebDrive, if you still have trouble connecting, please submit a ticket to our helpdesk at srthelpdesk.com and someone will help you out asap.

  • Good to know. Thank you. I didn't know these differences. I was doing all of these things in the interest of throwing enough diagnostic spaghetti on the wall, in hopes that something would end up being helpful. I only need SFTP. I figured out the problem thank goodness, as documented in my answer. – aliteralmind Jan 19 '15 at 21:15

It turns out that SFTP crashes if any text is output to the console. I added an echo to my ~/.bashrc, which killed it.

I've added the following to the very top of .bashrc:

  SFTP breaks if any thing is output to the shell, and it doesn't need
  anything in .bashrc anyway.

  Description of the following line of code: "If file descriptor 0, or 
  'the input' is connected to a terminal, which is true when you do: 
     ssh yourhost 
  but not when you do:
     ssh yourhost bash -s < script # here it's connected to 'script', a file"

  - https://serverfault.com/questions/485487/use-bashrc-without-breaking-sftp
  - http://www.openssh.com/faq.html#2.9
[ -t 0 ] || return

In addition, I've moved the echo, which I intended as a login intro message, to /etc/motd, as described in this answer

Thanks to dualbus and ishikawa on #bash.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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