Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kacy opened this issue Apr 9, 2012 · 47 comments
Closed

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

kacy opened this issue Apr 9, 2012 · 47 comments

Comments

@kacy
Copy link

kacy commented Apr 9, 2012

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! :-)

@kacy
Copy link
Author

kacy commented Apr 9, 2012

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

@kacy kacy closed this as completed Apr 9, 2012
@da2x
Copy link

da2x commented Apr 12, 2012

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.

@robertovalerio
Copy link

Same problem here. Mac<->Mac.

@nkuln
Copy link

nkuln commented Apr 13, 2012

@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_* 

@edw
Copy link

edw commented Jan 21, 2013

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

@hamiltont
Copy link

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?

@klippx
Copy link

klippx commented Sep 2, 2014

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

@ghost
Copy link

ghost commented May 20, 2015

@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.

@lebed2045
Copy link

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

@spiffytech
Copy link

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

@rubendepedro
Copy link

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

@paulomalvar
Copy link

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.

@jemus42
Copy link

jemus42 commented May 8, 2016

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.

@andersk
Copy link
Member

andersk commented May 9, 2016

@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'.

@jemus42
Copy link

jemus42 commented May 10, 2016

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

@lijinma
Copy link

lijinma commented Jun 29, 2016

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

@tnguyen14
Copy link

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?

@edw
Copy link

edw commented Jan 20, 2017

@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.

@tnguyen14
Copy link

@edw it is that path

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

@carloscabanero
Copy link

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

@tnguyen14
Copy link

@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.

@edw
Copy link

edw commented Jan 20, 2017

@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.

@tnguyen14
Copy link

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

@edw
Copy link

edw commented Jan 20, 2017

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

@tnguyen14
Copy link

@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 tri@Marks-iMac.home \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

@edw
Copy link

edw commented Jan 20, 2017

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

@tnguyen14
Copy link

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

@cgull
Copy link
Member

cgull commented Jan 20, 2017

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...)

@cgull
Copy link
Member

cgull commented Jan 20, 2017

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

@tnguyen14
Copy link

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

@jedisct1
Copy link

jedisct1 commented Apr 6, 2017

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

@ekkis
Copy link

ekkis commented Apr 21, 2017

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

@keithw
Copy link
Member

keithw commented Apr 21, 2017

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.

@tnguyen14
Copy link

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?

@javabrett
Copy link

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

@andersk
Copy link
Member

andersk commented Jun 9, 2017

@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'

@tnguyen14
Copy link

@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

@andersk
Copy link
Member

andersk commented Jun 11, 2017

@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)).)

@tnguyen14
Copy link

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.

@robtaylor
Copy link

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

@kernel1983
Copy link

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_*

@animatedcreativity
Copy link

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

@unresolvedsymbol
Copy link

unresolvedsymbol commented Oct 22, 2019

--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.

@naefl
Copy link

naefl commented Oct 29, 2019

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

@lgg
Copy link

lgg commented Dec 30, 2019

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

@jinnko
Copy link

jinnko commented Apr 21, 2020

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.

@eminence
Copy link
Member

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!

@mobile-shell mobile-shell locked as resolved and limited conversation to collaborators Apr 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests