Closed KangByungwoo closed 3 years ago
I finally figured it out. The main problem I think was that RMATE_HOST probably somehow got set to "auto" permanently while I was trying the second suggestion above. I think this sets RMATE_HOST to whatever IP address I am currently using for my local computer.
The solution was to add the following lines to ".bash_profile":
if ([[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]); then export RMATE_HOST=localhost export RMATE_PORT=52698 fi
I think you can change the port number to whatever port number you want, but I haven't tried that.
Hi,
yes ... 52698 ist just the default port, you can set it to whatever you like, either by setting it using the environment variable RMATE_PORT or by setting it in a configuration file as described in the README:
https://github.com/aurora/rmate#default-parameter-configuration
There's also an experimental branch where you can use UNIX sockets instead of port forwarding, but i didn't test it thoroughly:
https://github.com/aurora/rmate/tree/proxy-command
Have a look at the updated README in this branch to get an idea of how to use UNIX sockets with rmate.
Does this help ... ?
Hi,
Thanks a lot for your response, they look helpful! One question though: when we change the default host and port in the configuration file, do we also need to change the host and port number we use to ssh into a remote server? If so, can you give an example of how we do it? For instance, if I change the port number to 11 (I guess the port number can be arbitrary?), should I do "ssh -R 11:localhost:11 user@example.com"?
Also would it be possible for you to explain the difference between host=localhost vs auto (which was described in https://macromates.com/blog/2011/mate-and-rmate/) and how to use "host=auto" properly or whether you recommend it at all? Reading the description at the link, I thought host=auto might be an useful option for me since I am using a server with another user (though we are not sharing the same account) and sometimes it seems that programs he uses (such as Jupyter notebook or Lab) cross-talk with mate. But, I couldn't get it to work...
Hi,
ports below 1024 are so called "privileged ports", they can only be forwarded by root and you will probably not be able (and also should not) use them. So "whatever you like" was indeed not correct and i should have written "whatever you like as long as it's >= 1024 and it's not already used by some other service".
You do not need to configure the same ports in TextMate and rmate, ssh will handle the port-forwarding and mapping for you, so it would be perfectly fine to leave the port as is in your local TextMate (52698
) and use a different port on your remote host, for example 12345
. Now you would have to ssh into the remote machine as follows:
ssh -R 12345:localhost:52698 user@example.com
And on the remote machine you would use the port 12345
, either by commandline:
rmate -p 12345 <some-file>
or by setting the environment variable:
RMATE_PORT=12345 rmate <some-file>
Maybe using UNIX sockets would be better in your case, where you share the remote machine with someone else, because it would be less error-prone regarding the communication (assumed the implementation in rmate contains no bugs :wink:) and also more secure.
Got it, thanks for the info!
Great, you're welcome!
Hi,
I would really appreciate it if you could resolve the issue I describe below ASAP (I need to be able to use rmate again to run programs for a project with a deadline)
I recently found rmate is no longer working on a remote server, and I thought it might be because of a cross-talk with Jupyter Lab another user is using (on his account, just to be clear. We are not sharing the same account). For instance, when doing "sudo lsof -i tcp:52698" and then killing PIDs that appear from it by "sudo kill -9 [PID]", his Jupyter Lab process got shut down. Now, I wasn't totally sure whether rmate is not working because of the potential cross-talk, but I decided to change the default port number for rmate, 52698 to see if it solves the problem. I first followed jsmedmar's suggestion in https://stackoverflow.com/questions/35343853/how-to-use-sublime-text-over-ssh-with-multiple-computers-in-same-server-using-rs, but it didn't work. And then, I followed the suggestion in "Port Forwarding" section of https://macromates.com/blog/2011/mate-and-rmate/ (with RMATE_PORT=52699 instead of 12345 to be consistent with jsmedmar's suggestion above, but I guess this is not an important detail), but it still didn't work. So, changed all the files I modified back to their original configurations, which are: Packages/User/rsub.sublime-settings (used in the first suggestion; since this file didn't exist before I deleted it), ~/.ssh/config(used in both the first and second suggestions), ~/.bashrc (used in the second suggestion) in my local computer, and ~/.bash_profile (used in the first suggestion), /etc/ssh/sshd_config (used in the second suggestion) in the server. But, still I got the following error message: /usr/local/bin/rmate: connect: Connection refused usr/local/bin/rmate: line 412: /dev/tcp/[my IP address xx.xx.xx.xxx]/52699: Connection refused Unable to connect to TextMate on [my IP address xx.xx.xx.xxx]:52699
In particular, I don't understand why the port number in that error message is still 52699. I tried both "-R 52698:localhost:52698" in the ssh command and adding "RemoteForward 52698 localhost:52698" in ~/.ssh/config, but whatever I do, the port number in the error message was still 52699. Also, I remember when I got a similar error message before I tried the two suggestions above, I got "localhost" in place of [my IP address xx.xx.xx.xxx] in the error message (although I am not totally sure).
I've reinstalled rmate but I still get the exact same error message. My guess is that while trying the first and second suggestions above, I changed RMATE_HOST and RMATE_PORT environment variables explicitly on the server side and this might have made some permanent changes to them. But, at least when I echo those variables they did not return anything. Another guess is that creating a file called "sub.sublime-settings" in Packages/User directory of the local Sublime Text (as suggested by the first suggestion) might have had some affect, but this might be unlikely since when I use a different local computer to try rmate on the remote server, I get the exact same error message.
I looked into /usr/local/bin/rmate file, but I am not familiar with the shell script, and I couldn't figure out what's wrong. At least I could see that the error message I got depends on "$host" and "$port" variables and something must have gone wrong with them.
In any case, if you could give any suggestions to solve this issue and allow me to use rmate again, I would really appreciate that!