Forums

mosh

Just wanted to register my interest in being able to use mosh with PythonAnywhere. Once you've gotten used to remote login sessions that survive sleeping/waking your computer and changing networks, going back to plain old ssh is like going back to some terrible past you'd thought you'd left behind*. Any interest in adding mosh support? Thanks for your consideration.

* No lack of dramatic flair here.

Hi J,

I'm pretty sure that PA supports screen, which is similarly useful...

Many thanks, Robert

Ah, I'm not too bright. Mosh is a little different. Looks very cool, mind,

Thanks

Yes, screen/tmux does complement mosh but does not replace it.

And for what it's worth, I don't have screen installed in my PythonAnywhere environment:

16:45 ~ $ which screen
16:45 ~ $ echo $?
1

I actually just posted about that earlier today.

And I was the person who started the original screen thread!

Oh nice, I hadn't noticed. Solidarity!

(Wait, so when you said you were pretty sure PA supports screen above, were you mistaken, or am I missing it somehow?)

I don't think it has screen (sorry) :-(

However, can I just say thanks for pointing me to mosh. I love the Chrome shell, and it was super easy to install on my VPS.

Devs: please add an upvote for mosh from me!

I've created a ticket and given it 2 upvotes.

Glad to spread the word, Robert, and thanks for creating the ticket, Glenn!

Using linuxbrew I was able to brew install mosh, and now I can remotely log into PythonAnyhwere via mosh rather than ssh, but after displaying the PythonAnywhere welcome banner that is shown upon login and then my shell's welcome message, it never makes it to displaying an interactive prompt:

<<<<<<:>~ PythonAnywhere SSH. Help @ https://www.pythonanywhere.com/wiki/SSHAccess
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
(cursor hangs here)

Just thought I'd post here with my progress in case it helps anyone else / anyone else can take it from here.

One other clue, when I brew installed mosh I got this:

==> Installing mobile-shell
sudo: unknown user: root
sudo: unable to initialize policy plugin
==> Downloading http://mosh.mit.edu/mosh-1.2.4.tar.gz

==> ./configure --prefix=/home/j0452/.linuxbrew/Cellar/mobile-shell/1.2.4_1 --enable-completion
installed software in a non-standard prefix.

Alternatively, you may set the environment variables OPENSSL_CFLAGS
and OPENSSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

I may return to this when my yak-shaving batteries are charged back up, but for now I'll leave it there.

linuxbrew looks interesting.

Good luck with that yak shaving.

Is there an equivalent of bashrc, that mosh needs to jump into an interactive shell?

Has this ever been completed? Also interested in using mosh =)

No, we haven't done anything on this. To be honest, it's quite low on our priority list since we believe that most of the benefits of mosh are provided by our in-browser consoles and general system performance and features are taking priority at the moment.

Tmux is available (and I'd heartily recommend stealing the excellent screen bindings for it). I'm definitely intrigued about the thought of using Linuxbrew for installing non-root applications. I was just pining for the latest Tmux (2.4? as it is only 1.8 is on the dangermouse image) and Linuxbrew could be an answer for that. I've used it to bootstrap Chromebrew on my Chromebook in the past and it is fantastic.

I'll certainly update the thread if I come up with anything.

We don't tend to chase the latest versions of all of the packages that we install because that would leave us with no time to do anything else. We tend to follow what is packaged with the distribution that we're building from. If you absolutely need to chase the new shiny, then LinuxBrew may be the way for you to go.

After a couple days of futzing with this I think I have the yaks shaved in the proper order to make this setup repeatable, but I'm fairly certain this won't work on free accounts due to the myriad external download links that brew uses pulling the software from the original hosting locations.

Because the certificates PyA uses appear to come from an older "stable" distribution they sometimes throw warnings when sites have an updated certificate that they don't trust yet, and currently Linuxbrew (and Homebrew) don't have a way to pass the underlying curl command the insecure flag -k. To work around this we can use the latest certificate trust bundle from Curl's own website to work around this in some cases.

Notes:

# Curl -L follows redirects, -O saves using server file name
# Brew requires a tmp dir with world writeable and sticky bits set

Install Linuxbrew following directions from https://linuxbrew.sh.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
PATH="$HOME/.linuxbrew/bin:$PATH"
echo 'export PATH="$HOME/.linuxbrew/bin:$PATH"' >>~/.bashrc
# Occasionally the first brew command fails if the tmp directory isn't readable
brew doctor
# This may fail without sudo, but PyA users aren't in the sudoers group
chmod +t /tmp
# A workaround if the above doesn't work is to create your own ~/tmp and use it
# mkdir ~/tmp; chmod +t ~/tmp; export HOMEBREW_TEMP=~/tmp
# You may also want to add the export above to your ~/.bashrc

Commands to fix brew for PyA:

mkdir -p ~/.local/ssl/; cd ~/.local/ssl/; curl -L -O https://curl.haxx.se/ca/cacert.pem
CURL_CA_BUNDLE=~/.local/ssl/cacert.pem brew install curl
# brew installed curl uses its own certificates instead of just the OS ones

Now you can use brew to install whatever software you desire.

brew install mosh
brew install tmux

It would be great if a PythonAnywhere staff member could test this in a fresh free and fresh paid user environment and make sure I haven't missed anything. I currently don't have my environment backed up to the point where I could blow it away and retest.

Thanks for the detailed instructions! We'll double-check against fresh free and paid accounts, and report back.

It appears that Mosh needs to open a UDP port between 60,000 and 61,000 (or use a custom port) and these don't appear to be open on PythonAnywhere, and judging from a couple other posts, opening additional ports is a low priority as it increases maintenance and monitoring requirements.

It would be great if 8080 were open for TCP/UDP and running a secondary web server instance for an app admin interface or something similar (that could also be used for Mosh), but I definitely understand not wanting to have to maintain the extra complexity of more ports in the firewall times however many users there are.

That said, Linuxbrew works great for getting the latest Tmux and other goodies, so Mosh would have just been extra icing on the cake.

Here are some updated install instructions for Linuxbrew -- these should work on any paid account:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
export PATH="$HOME/.linuxbrew/bin:$PATH"
echo 'export PATH="$HOME/.linuxbrew/bin:$PATH"' >>~/.bashrc
mkdir ~/tmp; chmod 755 ~/tmp; export HOMEBREW_TEMP=~/tmp
echo 'export HOMEBREW_TEMP=~/tmp' >>~/.bashrc
cd ~/.cache/Homebrew/
wget https://homebrew.bintray.com/bottles-portable/portable-ruby-2.0.0-p648.x86_64_linux.bottle.tar.gz
brew doctor

+1 for Mosh support (allow UDP on Mosh ports)

Thanks! I've added an upvote to the ticket on our to-do list.

Have there been any updates on this?

No there have not.

I followed the updated install instructions for Linuxbrew, but get the following error in brew doctor: /home/philiplessner/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin/ruby: No such file or directory @ rb_readlink - /proc/self/exe (Errno::ENOENT)

This Stack Overflow answer looks like it might be useful...?

Hello, any news on this maybe?

I would also really like to use mosh from my iPad, but getting the following error when installing linuxbrew: Traceback (most recent call last):
/home/mee/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin/ruby: No such file or directory @ rb_readlink - /proc/self/exe (Errno::ENOENT)

Would be great if it would be supported. thx

I've switched on an experimental feature for your account -- our new virtualization system -- which might help. Could you try again in a newly-created Bash console?

Seems to work from the inbuilt bash, thanks. Just seems to be a bit slow, so it eats up my CPU seconds.

It seems there is an issue with protobuf dependency when building brew install mosh. There is a github issue open already. https://github.com/Homebrew/linuxbrew-core/issues/17115

Furthermore it seems the experimental feature you mentioned is only available from the inbuilt console, and not from one that I spawned using SSH from my iPad. For example using brew doctor from SSH bash gives the ruby file missing error from above, while it works on the new bash from the homepage.

Good point about the SSH limitation, I should have mentioned that. The experimental virtualization system works everywhere apart from SSH and in Jupyter/IPython notebooks.

Re: the brew problem -- I guess we'll have to wait until they fix that before mosh will work, then.

add upvote to mosh

noted