Jon Simpson

rmate + SSH RemoteForward

14 Dec 2011 — textmate2, rmate, ssh forwarding

[Update 23 Dec 2011: The Textmate blog now has a post explaining rmate and how to set up rmate over SSH, including a useful tip about using a wildcard host block instead of adding the RemoteForward directive to every host block.]

After reading Ernie Miller’s post about getting to grips with the new rmate tool present in the freshly released TextMate 2 alpha, it struck me that this could be a useful addition to using SFTP disk mounting solutions like Transmit’s Disk (which I’ve been mostly happy with, barring some caching/delay issues).

Ernie’s post suggests providing arguments to ssh to forward traffic from remote port 52698 on the server to the same port on the local machine when connecting. Because this bind is on the remote side, it’s possible to have multiple servers using rmate with a single copy of TextMate locally, without having to change any settings.

To make this setup easier to use, it’s worth putting the arguments to set up the remote port forward into the ssh configuration file, usually found at ~/.ssh/config.

If you’ve already set up configuration blocks to set options for some of your existing connections, you can add the line

 RemoteForward 52698 localhost:52698

to the block to automatically set the connection up every time you connect. If you haven’t already set up a configuration block, you’ll need to specify the server in question (an example is below, there are many other options for the ssh configuration file, see the man page for ssh_config):

Host example.com
	Hostname example.com
	RemoteForward 52698 localhost:52698

Repeat the configuration for every server you want to use rmate on - note you’ll also have to install the rmate script on each machine as well.

Note that once one ssh connection has been established, subsequent connections will produce a message:

Warning: remote port forwarding failed for listen port 52698

This message is harmless, as the forward can only be set up once and one forward will work for all ssh connections to the same machine. The original ssh session that opened the forward will stay open when you exit the shell until all remote editing sessions are finished.


 Home