[mosh-devel] does mosh support sshpass

C.v.St. stucki-spam at t-online.de
Sat Oct 27 08:03:20 EDT 2018



Am 25.10.18 um 20:52 wrote rohit poddaturi:

> alias latite="mosh --ssh="sshpass -p "<password>" ssh -o StrictHostKeyChecking=no" rpoddaturi at latite"
> 

The manual defines for mosh to set --ssh=COMMAND,
so you CAN give parameters. BUT you wrap multiple
layers of command line, parameter, and alias together
and tried to do this with 'one set/level of quotes'.

This can not work, and you need to sort out, what
is in which string/command/alias and in which order
it will be defined and used.

Another thing is, you NEVER should run something
with a password in the command line! Everybody
can see, which programs run, and so read it.
So first thing should be, to learn how to use
'key logins' in ssh and to put the key into
an agent to keep, so there is no extra password
question-program necessary.

By the way - IF you simply want to predefine, that
connecting to a specific host needs specific options
or a different username, you can set such defaults
for each host in ~/.ssh/config!

But if you really need it in your mailed alias, consider:

1) in the end the whole 'alias' must be 'one string':
$ alias whatever="some command with some parameters"
2) INSIDE the alias something needs quoting, so you must
   write the second level in a way, that it is packed
   inside and is not lost:
$ alias whatever "echo some command \"with blank in parameter\" and more"
3) you will need to know the difference between "…" and '…':
$ alias whatever="echo some command 'with blank in parameter' and more"
or the other way around
$ alias whatever='some command "with blank in parameter" and more'
4) your "password" is even one more layer being inside of --ssh !

So all together the following might work

$ alias latite="mosh --ssh='sshpass -p \"<password>\" ssh -o
StrictHostKeyChecking=no' rpoddaturi at latite"

- The outside " keeps together the alias
- The ' hold the -ssh contents
- The \" INSIDE of " are simply kept in place

May be, this explains a bit.
  Stucki


More information about the mosh-devel mailing list