ProblemThe server I referred to is almost on our control. It's a virtual server and we have a domain and lots of open ports. No own IP address though. That we have to share with couple other servers. That's why we don't have access to the ports necessary for Mosh. Mosh works by taking a normal SSH-connection and starting a mosh-server on user space. It chooses an open port from 60000–61000. Too bad we don't have access for those.
Solution 1You can choose the port outside the default range. It's easy. Just connect with
$ mosh -p <port> <user>@<host>
I really don't see this as an option. Our server has at the moment about 20 users. Some more technically oriented than others. To connect, one has to know the available port range (which is 41000-41999 something...) and available port at the moment, since there are 20 other users. Maybe we could give everyone two or three ports for their personal use...
No. This is not an option.
Since the default port range is hardcoded in the source and there is no config file, I thought I'd change the code. In version 1.2.3, in file mosh-1.2.3/src/network/network.h there are lines
static const int PORT_RANGE_LOW = 60001;
static const int PORT_RANGE_HIGH = 60999;
Change those to preferred ones, make, make install and things should work.
I didn't get into testing this before I found myself once again bothering the developers on IRC. This seems to be an efficient method of solving problems with open source. I only hope the developers don't mind...
I had to compile this from source after all, but without any changes. In the Git version they have a feature of giving a port range as an argument to mosh-server. Mosh-server is the program mosh runs on server side after an successful SSH-connection and mosh-client then connects to mosh-server. They both have to know which port to use.
I installed mosh on /usr/local and renamed /usr/local/bin/mosh-server to /usr/local/bin/mosh-server.real. Then I created a new /usr/local/bin/mosh-server
/usr/local/bin/mosh-server.real $@ -p 44800:44999
Mosh calls for mosh-server, which again calls for mosh-server.real passing the original arguments and adding its own port range.
Users don't have to know any of this. They can now connect with
$ mosh <user>@<host>
and everything works as it should.
Best solution (to my opinion)
...would be a server side config file to define the default ports. Too bad there is no such file at the moment.