Mosh: /usr/local/bin/mosh: Did not find mosh server startup message.

Created on 10 Apr 2012  Â·  47Comments  Â·  Source: mobile-shell/mosh

I installed via Homebrew, but I can't seem to log into any servers.

$ mosh user@host (user and host are different)
user@host's password: (i entered the correct password)
bash: mosh-server: command not found
Connection to host closed
/usr/local/bin/mosh: Did not find mosh server startup message.

Any help would be appreciated. Thanks! :-)

Most helpful comment

The problem is that /usr/local/bin is not in you server's PATH. This is probably because Mosh invokes Bash as an interactive non-login session. This means that your ~/.bashrc is read while you ~/.bash_profile is _not_, so you should make sure you have something like this in your ~/.bashrc:

export PATH=/usr/local/bin:$PATH

All 47 comments

Wow. I feel like an idiot. I forgot to install mosh-server on the host. Sorry.

I also have this issue, but unlike you I have mosh is installed on the both server and client.

en_US.UTF-8 on Ubuntu oneiric server edn. and installed via Homebrew on Mac on client side.

Same problem here. Mac<->Mac.

@zcode Possibly related to env transfer. Mac sends LC_CTYPE to the Ubuntu server. You may want to comment out SendEnv line in /etc/ssh_config:

$ env | grep LC_
LC_CTYPE=UTF-8
$ cat /etc/ssh_config | grep SendEnv
#   SendEnv LANG LC_* 

The problem is that /usr/local/bin is not in you server's PATH. This is probably because Mosh invokes Bash as an interactive non-login session. This means that your ~/.bashrc is read while you ~/.bash_profile is _not_, so you should make sure you have something like this in your ~/.bashrc:

export PATH=/usr/local/bin:$PATH

Sorry to resurrect a dead item, but @edw was correct for me and I'm wondering if there is a need to report to the mosh invoker the true error instead of the symptom. Using mosh --ssh="ssh -vv" <you>@<yours> shows that bash reports that mosh-server is not found. However, the error message the client receives is that the startup message was not received. Wouldn't it be at least good to append something to the current message about ensuring that mosh-server is in the PATH?

I had the same problem and what @nkuln said fixed it for me.

@edw was correct for me as well. You can confirm if this is your issue with:

$ ssh your-host.dev /usr/bin/which mosh-server
# nothing
$ ssh your-host.dev echo \$PATH
/usr/bin:/bin:/usr/sbin:/sbin

Also relevant In OSX Yosemite, why can I set many environment variables for GUI apps, but cannot set the specific variable PATH. Previously you could set PATH for all the things via launchd, but Apple removed that in Yosemite because security.

Lastly, a plug for zsh which "just works" when /etc/paths contains /usr/local/bin regardless of interactive/non-interactive invocation.

I still have this error and advice of @edv didn't work for me

@edw's solution worked for me, Linux -> Mac via homebrew

yap, same problem here (OSX<->OSX), homebrew installation won't find mosh-server path via ssh. Two ways to solve this:

  • $ mosh --server=/usr/local/bin/mosh-server megaminilan
  • apply ewd solution

Following up on rubendepredro's solution. Since I installed mosh using MacPorts (on both ends), invoking mosh using "--server=/opt/local/bin/mosh-server" totally does the trick for me.

I'm confused. While this solution works, I did not expect the following:

Lukas::dufte ➜  ssh knorke echo $(which mosh-server)
/usr/local/bin/mosh-server
Lukas::dufte ➜  mosh knorke
zsh:1: command not found: mosh-server
Connection to knorke.local closed.
/usr/local/bin/mosh: Did not find mosh server startup message.

So… ssh finds mosh-server correctly, but mosh doesn't?

EDIT:
Scenario is OSX -> OSX, both have mosh installed via homebrew.

@jemus42 When you ran ssh knorke echo $(which mosh-server), the argument $(which mosh-server) was expanded on the client side. Try ssh knorke 'echo $(which mosh-server)' (with single quotes, not double), or simply ssh knorke 'which mosh-server'.

Well, that's embarrassing. Thanks for clearing that up m)

I think this is an ordinary issue for many users, getting start document is too simple.

I have the same problem as shown by @toolbear

:; ssh home echo \$PATH
/usr/bin:/bin:/usr/sbin:/sbin

I have tried adding /usr/local/bin into $PATH in ~/.bashrc as suggested here, but that still doesn't work. I'm still getting the bash: mosh-server: command not found error.

Does anyone know what else I could try/ debug?

@tnguyen14, If you can execute mosh-server from your shell on the machine, do a which mosh-server and make sure _that_ path is in your $PATH. The solution is not to put /usr/local/bin into your path, it's to make sure the directory containing mosh-server is in your $PATH.

@edw it is that path

:; which mosh-server
/usr/local/bin/mosh-server

@tnguyen14 did mosh --server=/usr/local/bin/mosh-server not work in your case?

@carloscabanero it does. But I don't wanna type the whole thing every time I need to log into the server.

If there's a more permanent solution, it'd be great.

@tnguyen14, is it in /usr/local/bin/ on the machine you're moshing _from_ or the one you're mashing _to_? IIRC, we're talking about the mosh-server binary location on the destination machine.

@edw good clarification. it is on the destination server machine I'm moshing to.

@tnguyen14, dumb question: is bash your default shell? Also: try moshing in using the --server option, execute env, and show us the output.

@edw yes default shell is /bin/bash

:; env
BOLD=
GREEN=
LESS_TERMCAP_mb=
LESS_TERMCAP_md=
RESET=
LESS_TERMCAP_me=
SHELL=/bin/bash
TERM=xterm-256color
HISTSIZE=100000
CLICOLOR=1
YELLOW=
SSH_CLIENT=64.179.64.5 51590 22
TMPDIR=/var/folders/gk/ryxkp91d79j67l51gk956c3c0000gp/T/
LESS_TERMCAP_ue=
ORANGE=
SSH_TTY=/dev/ttys000
HISTFILESIZE=100000
USER=tri
BLUE=
SSH_AUTH_SOCK=/tmp/ssh-T2JZS699aR/agent.66828
LESS_TERMCAP_us=
LSCOLORS=CxFxExDxBxegedabagacad
MAGENTA=
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Users/tri/dotfiles/node_modules/.bin:/Users/tri/bin:./bin:./node_modules/.bin:.
MAIL=/var/mail/tri
PWD=/Users/tri
EDITOR=nvim
BASE16_THEME=default-dark
LANG=en_US.UTF-8
PS1=\A [email protected] \w\n`if [ 0 == 0 ]; then echo \[$GREEN\]':;'; else echo \[$RED\]':'\[$GREEN\]';'; fi` \[$RESET\]
HISTIGNORE=&:[  ]*:exit:ls:bg:fg:history:clear
HISTCONTROL=ignoredups:erasedups
PS2=\[\]→  \[\]
RED=
NCURSES_NO_UTF8_ACS=1
HOME=/Users/tri
SHLVL=2
PURPLE=
LOGNAME=tri
LESS_TERMCAP_so=
SSH_CONNECTION=64.179.64.5 51590 192.168.1.4 22
FZF_DEFAULT_COMMAND=rg -uu --files -g !.git -g !node_modules
GOPATH=/Users/tri/go
HISTTIMEFORMAT=%F %T
WHITE=
LESS_TERMCAP_se=
_=/usr/bin/env

@tnguyen14, I am completely baffled. I, for what it's worth cannot connect to my own MacBook without specifying a --server argument.

@edw yeah this is me trying to connect to an iMac. SSH works fine. Mosh connecting to a linux box also works fine.

If @tnguyen14 sets PATH in his .profile or .bash_profile or .bash_login, but not in .bashrc, that might explain why it comes up OK in the above debug output, but fails for Mosh invocation.

(I used to believe .bashrc should not edit $PATH or do anything else related to interactive or tty sessions, but Mosh is making belief harder...)

Also, adding /usr/local/bin to my PATH in .bashrc on OS X 10.12 works fine for me.

@cgull I'm adding it to PATH in .bashrc.

For zsh (installed using Homebrew) the path can be set in ~/.zshenv.

from the docs: "Behind the scenes, the mosh wrapper script will SSH to the server, start up mosh-server, and then close the SSH connection" it is easy to think the wrapper script will transfer mosh-server to the target before running it. the documentation NOWHERE says I have to install mosh-server on the target. in fact, it would be a much better product if it would just install itself at the target without my having to do it

Thanks for this feedback. Our website is pretty clear (The first bit of text under "Getting Mosh" is "The Mosh package should be installed on both the client and server. Please find your platform below for installation instructions."), but we'll happily take a pull request to the mobile-shell/moshweb repo if you have a suggestion.

We've considered the idea of trying to have mosh automatically install itself on the server (a server whose architecture might be different than the client!), but the complexity of trying to do this reliably for any pair of architectures, and the fact that no other program works like this, has weighed against. You have to install sshd on the server to use SSH; you have to install mosh-server on the server to use Mosh.

Does anyone know why I might have the issue I'm seeing, where I have to specify the path to mosh-server on the mosh command, even though the $PATH declared in .bashrc includes /usr/local/bin?

I think because the mosh perl script execs mosh-server directly, not via any shell. So you are probably seeing sshds default path.

@javabrett No, the mosh script execs ssh, which connects to sshd, which launches your default shell and tells it to run mosh-server (via -c). Whether your shell reads dotfiles when launched from sshd in this manner, and which ones, is entirely up to your shell.

@tnguyen14 See what you get from these commands:

ssh SERVERNAME 'echo "$PATH"'

ssh SERVERNAME 'mosh-server --help'

@andersk

17:57 tri ~
:; ssh home 'echo "$PATH"'
/usr/bin:/bin:/usr/sbin:/sbin
17:59 tri ~
:; ssh home 'mosh-server --help'
bash: mosh-server: command not found

@tnguyen14 Well, now you see what the problem is and you can debug it without the involvement of Mosh. Once you can make the PATH output by ssh home 'echo "$PATH"' include the location of mosh-server, it will be found automatically by mosh.

(It sounds like your server is one of the systems where bash has been configured without SSH_SOURCE_BASHRC. You may be able to use ~/.ssh/rc (see sshd(8)) or ~/.pam_environment (see pam_env(8)) or ~/.config/environment.d/*.conf (see environment.d(8)).)

I figured out what was wrong with my setup. I had this in my ~/.bashrc to skip it when not running interactively

[[ -z $PS1 ]] && return 

Instead, I modified it:

[[ -z $PS1 ]] && export PATH="$PATH:/usr/local/bin" && return 

and that fixed my issue.

I needed to run sudo locale-gen en_US.UTF-8 on the server

On two Macs, one is okey and another one doesn't work. Solved by

sudo vi /etc/ssh/ssh_config

and change the SendEnv

Host *
#    SendEnv LANG LC_*

Nothing worked for me but this surely did, please check this answer: https://askubuntu.com/a/229512

I added these 2 lines to /etc/environment on Ubuntu Server 16.04:

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

--no-ssh-pty resolved this on Void Linux -> OpenWRT, must an issue with the default dropbear configuration in OpenWRT but leaving this here in case it helps someone else.

In case someone stumbles on this as I did and none of the fixes work: the -i flag is not definied in mosh, so you need to

ssh-add <your private key file path>

and then log in without the -i flag

mosh name@host

I had the same issue. Check that you have correctly set up locale.

For me LC_ALL wasn't set.

image

fixed with: sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

FWIW - none of the suggestions here worked for me. I eventually discovered that the server-side was running dropbear (on a Raspberry Pi). Switching to openssh-server resolved the issue.

The issue with dropbear is discussed in #819.

Since the original issue was filed (and resolved) 8 years ago, I'm locking this issue. If anyone else is having problems with mosh, please open a new issue so that we can discuss the specifics of your environment/problem.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xapple picture xapple  Â·  7Comments

jiyinyiyong picture jiyinyiyong  Â·  7Comments

Shoozza picture Shoozza  Â·  7Comments

shibumi picture shibumi  Â·  5Comments

lilyball picture lilyball  Â·  7Comments