30

I am trying to use rsub to create tunnel in ssh to sublime text, I run the command rmate .profile but i get the following response. I am using wateroof to open the ports 52968 on 1p4 and ip6, I followed the insturctions here and its just not working

I am running osx on my local machine and ubuntu 12.04 on my remote machine I am ssh into on digitalocean

root@anderskitson:~# rmate .profile
/usr/local/bin/rmate: connect: Connection refused
/usr/local/bin/rmate: line 186: /dev/tcp/localhost/52698: Connection refused
Unable to connect to TextMate on localhost:52698
2
  • In my case, I had a valid Host audio line in my .ssh/config file, but I was using ssh music.local to connect to it (bypassing my ssh alias) and its necessary RemoteForward.
    – Phrogz
    Commented Apr 19, 2016 at 23:42
  • I've got this problem, but it's a bit intermittent. It works fine until I put the computer (Mac OSX) to sleep. After waking it up, the only way to get the VS Code to open the remote files is to restart the computer. Any ideas, why that could be happening?
    – crs1138
    Commented Sep 9, 2019 at 10:29

9 Answers 9

56

I was having the same problem.

Let remoteHost = the IP or hostname of the machine you're attempting to ssh to.

I ran ssh -R 52698:localhost:52698 remoteHost from my local machine, after whice rmate .profile on remoteHost worked.

That led me to determine that ~/.ssh/config on my local machine was incorrect.

I set ~/.ssh/config to look like this:

Host remoteHost
  RemoteForward 52698 localhost:52698

It's been working solidly since I made that change.

5
  • 10
    I was having the same problem as well and changing my .ssh/config didn't fix anything, but buy adding -R 52698:localhost:5269 to my ssh command, it worked perfectly. (thanks EricaJoy)
    – Ross R
    Commented Oct 18, 2013 at 17:34
  • 4
    Maybe I didn’t read this too well, but just for anyone else who makes my mistake, don’t take “remoteHost” literally. remoteHost is just the name of your server block in ~/.ssh/config—so add RemoteForward 52698 localhost:52698 to the end of your block, not as some new block. Swap “remoteHost” for “myServer” or whatever the Host is in your config block. Commented Sep 8, 2015 at 0:54
  • 2
    Excellent answer. Note: I am using the rsub package from ST3, so I will be doing rsub myfilename.txt instead of rmate.
    – Nubtacular
    Commented Oct 12, 2015 at 19:49
  • @EricaJoy, I'm having the same issue as Ross R and I think my ssh config file looks the same as yours.. it just doesn't work that way. I have to include the -R 52698:localhost:52698 at login.. not sure how yours worked..
    – olala
    Commented Jan 14, 2016 at 20:33
  • I'm connecting to the remote server using username and a passowrd..How do I specify the password on my config file. Commented Sep 26, 2017 at 16:37
24

For anyone getting this same error using PuTTy on Windows, this commenter gives great instructions:

  1. In PuTTy's config window, nagivate to the Connection > SSH > Tunnels pane
  2. In the "Source Port" field, type 52698
  3. In the "Destination" field, type 127.0.0.1:52698
  4. Select the "Remote" and "Auto" radio buttons
  5. Click the "Add" button
  6. Go to the Session pane and save if you want to preserve these settings.

Here's an image which does the explaining visually:

rsub configuration windows putty sublime text ssh

6

I had the same issue and here is what works for me. If you have multiple servers you want this to work for, do the following as exactly shown here:

Host *
  RemoteForward 52698 localhost:52698

I consulted this link: configure SSH config file and realized you can use * in config file.

Wildcards are also available to allow for options that should have a broader scope.

4

I was trying to set this up for the first time using VS Code and got the generic "Connection refused" error even though my configuration seemed fine. It turned out to be because I hadn't reloaded the IDE after installing the rmate extension (Remote VSCode). Make sure that the rmate server is active on your local machine, whatever IDE you're using.

1
  • 1
    Thanks! Can't believe I didn't do this. Sometimes you gotta start at the beginning.
    – Architek1
    Commented Apr 5, 2018 at 14:05
4

I had the same problem and gone through most of the blogs, I did everything that was told. At last, I found myself that textmate or submile editors are closed(force quit), this caused the problem.

1
  • 1
    Yeah no one wrote to open Submlime first :) Thank You
    – BartZalas
    Commented Oct 10, 2018 at 11:09
3

I had the same problem and fixed with replacing the HOSTNAME with the actual IP-Address when connecting:
e.g.: ssh [email protected] to ssh [email protected]

2

For example my SSH config ~/.ssh/config file to connect with DigitalOcean with Remote Forward looks like:

Host DigitalOcean
  Hostname xxx.xxx.xxx.xxx
  User username
  RemoteForward 52698 localhost:52698

and is called in a terminal

ssh DigitalOcean

rmate then connects fine with my local Atom editor

1
  • Using the Host value from ~/.ssh/config did the trick for me, thanks! When just connecting via ssh [email protected], the connection is refused.
    – Fabian
    Commented Dec 9, 2019 at 10:55
0

rmate stopped working for no apparent reason. Turns out I had tripped the 'man in the middle' check. I saw this warning when doing ssh --

\@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

In my case, this warning was expected so I ignored it. This may not apply for you, so verify host identity. Didn't realize this line at the end of the warning --

Port forwarding is disabled to avoid man-in-the-middle attacks.

No wonder rmate stopped working. Verifying host identity and then clearing out offending entry from ~/.ssh/known_hosts made the warning go away and rmate started working again.

0

I run into this issue occasionally, and at least for my setup (which might be quite particular), I have found that killing zombie instances of ssh sessions does the job.

My particular setup :

I run Linux through a VM (VMWare Fusion) on my OSX host. Then I ssh into the the Linux host from OSX, and launch sublime from the Linux side. I usually have several ssh sessions running.

I recently rebooted my Mac (without first shutting down the VM, which was probably bad), and once I got back into the VM, was unable to launch Sublime - got the "connection refused" error mentioned by the OP.

So I did a ps aux on the Linux side, and looked for all instances of :

root      657399  0.0  0.1  13956  9332 ?        Ss   14:52   0:00 sshd: user [priv]
user      657461  0.0  0.0  14088  5420 ?        S    14:52   0:00 sshd: user@pts/1

(where user is my username). I killed the user jobs, e.g. 657461 above, and Voila! Every thing works now. Of course, in the process of killing these jobs, you are likely to kill the ssh session you are currently in, so you will have to log back into your session.

This might not work for users who don't have the necessary kill privileges on their remote machine, so don't know how useful this is, but thought I would put it out there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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