henrikpersson / rsub

Use rmate with Sublime Text.
459 stars 70 forks source link

rsub with multiple computers in the same server #60

Open jsmedmar opened 8 years ago

jsmedmar commented 8 years ago

I'm trying to use rsub with multiple computers on the same server, however, it only works for one. When I try to use it from other computers, files are opened in the first computer. I tried following the instructions in the Port Forwarding section of this blog. But couldn't solve it. Any suggestions?

jsmedmar commented 8 years ago

I found a work around, which is described here. I'm wondering why this package does not enable to set user specific settings. Anyway, I truly love rsub. Thank you!

ghost commented 8 years ago

The workaround you linked doesn't seem to be working for me. Any suggestions?

jsmedmar commented 8 years ago

@lgsds can you explain further? What are you experiencing? The same file is opening in two computers? Nothing happening at all? I'll review my SO post to see if I missed something.

jsmedmar commented 8 years ago

Make sure in this file Packages/User/rsub.sublime-settings you use different ports for the different machines.

ghost commented 8 years ago

When I follow the post I get the following errors:

~/bin/rsub: connect: Connection refused ~/bin/rsub: line 326: /dev/tcp/localhost/52699: Connection refused Unable to connect to TextMate on localhost:52699

But when I set it up using the default port, 52698, it works just fine.

jsmedmar commented 8 years ago

Do you have sublime opened when you try to connect? Perhaps, could you share your settings?

S

On Apr 14, 2016, at 11:20 AM, lgsds notifications@github.com wrote:

When I follow the post I get the following errors:

~/bin/rsub: connect: Connection refused ~/bin/rsub: line 326: /dev/tcp/localhost/52699: Connection refused Unable to connect to TextMate on localhost:52699

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub

ghost commented 8 years ago

I do. I set it up using the same settings as the SO post:

# Packages/User/rsub.sublime-settings
// rsub user settings
{
    /*
        rsub listen port.

        IMPORTANT: Use a different port for each machine.
    */
    "port": 52699,

    /*
        rsub listen host

        WARNING: it's NOT recommended to change this option,
        use SSH tunneling instead.
    */
    "host": "localhost"
}
jsmedmar commented 8 years ago

Hey @lgsds, I went through this process again for one of my colleagues computer and I was having the same issue as you...

Surprisingly, my problem was that I had an extra white space at the end of the name of the rsub settings file, it was called Packages/User/rsub.sublime-settings• (being a white space) instead of Packages/User/rsub.sublime-settings.

Once I fixed that, everything worked as expected. I didn't do anything different from what is described in StackOverflow.

jsmedmar commented 8 years ago

If you copy pasted the name from the SO post, you are likely to have the same problem because that name had an extra white space (which I just corrected).

nemeth-it commented 6 years ago

In our case there was two local machines which wanted to connect on the same server and the same user. We solved it by simply duplicate the rmate-script on the remote machine, rename it and change the port-number in the script itself.

All other changes locally was also necessary liked mentioned in this thread. Worked like a charm, but a support for multiple users for the same command would be nice.

KES777 commented 6 years ago

If you connect over ssh you may export RMATE_PORT environment variable and do remote forward. Because I am the only user I put this export into ~/.bash_aliases

if [ -z "$SSH_CLIENT" ]; then
        export EDITOR="subl"
else
        export EDITOR="rsub --port 52697"
        export RMATE_PORT="52697"
fi

and also put into ~/.ssh/config next:

host    your_host_alias
        user user_name
        hostname host.domain
        PreferredAuthentications publickey
        port 22
        identityfile /path/to/your/key
        RemoteForward 52697 127.0.0.1:52698

How to pass the ENV variable you can see here

  1. Then each user setup different RMATE_PORT. For example 11111/22222 correspondigly
  2. Fix his ~/.ssh/config with new value
    RemoteForward 11111 127.0.0.1:52698

    For each connection the environment will have different RMATE_PORT so your two users will not interfere. And do not need to patch rsub and/or create copy or it

hope this helps to you

magnosis commented 5 years ago

I see how to customize the port, but I fail to understand how to have 1 local Sublime instance able to edit files on multiple remote servers at once.

Every time I open an SSH connection to 2nd, 3rd, etc. remote hosts, the previous hosts cannot connect to Sublime. One local Sublime port won't accept connection from multiple remote hosts.

Is this possible at all? Can I get sublime to open, say, 10 ports, 1 for each of 10 remote hosts?

KES777 commented 5 years ago

@magnosis

One local Sublime port won't accept connection from multiple remote hosts.

You are wrong here. The sublime when listening port 52698 (actually rmate plugin) it acts like server. and can accept unlimited count of connections from different remote hosts. In same way as for example your DB server.

Is this possible at all? Can I get sublime to open, say, 10 ports, 1 for each of 10 remote hosts?

yes that is possible. I have described here how