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

Having a .moshrc (equivalent to .ssh/config) file to be able to specify per-host configs #431

Open
lemoinem opened this Issue May 29, 2013 · 20 comments

Comments

Projects
None yet
@lemoinem

lemoinem commented May 29, 2013

Hi,

I think this would go a long way improving the usability of mosh to be able to have a .ssh/config equivalent.

Unfortunately, ssh complains about unknown directives in .ssh/config so we will need a new file (I also think it's good practice to do so anyway).

The format could be simple (.ssh/config sounds a pretty good example: easy to write, easy to parse).

Useful configs to include: hostname, port, mosh-server, eventually ssh and command (in some weird case). Later: enable/disable OOB data (#423) on a per-host basis.
Some of the configs such as hostname, agent forwarding, X11 forwarding, etc... could actually be extracted from .ssh/config directly.

I think it's much better than aliases because it's seamless and consistent. Plus the fact that mosh already seamlessly use .ssh/config makes it quite irritating to be able to use aliases only for specifying a couple of argument for a given host. If many hosts requires a custom config multiplication of aliases could also clutter the shell. Plus we always have to remember which hosts works out-of-the-box and which needs an alias. All this disappears with a .mosh/config config file.

Security-wise, since it's already done by ssh (and actually allows a much bigger control on the connection since it could change the Hostname we are connecting to, define a ProxyCommand, etc...), If the file is secure, I don't see a very big security issue here.

@lemoinem

This comment has been minimized.

Show comment
Hide comment
@lemoinem

lemoinem May 29, 2013

FTR, IRC discussion:

11:40 < lemoinem> I was wondering if there has already been a discussion regarding a .ssh/config-like file for mosh...
11:41 < grawity> What options would it have?
11:41 < lemoinem> I think it's a kind of small feature code-wise that would go a great way to improve the usability.
11:41 < lemoinem> On the top of my head, port is the one I see the most usefull
11:41 < achin> -p is the only useful option to mosh, right?
11:41 < lemoinem> yeah, but mosh-server could be too
11:41 < achin> true
11:42 < achin> in the past, people have recommended aliases for this, but i can see how a .mosh-config might be useful
11:42 < lemoinem> (plus, with oob data coming with mosh 1.3 (iirc), we could enable/disable it on a per-host basis...)
11:44 < lemoinem> otoh, I understand it might still be a bit of work code-wise, but I guess it would already be nice to have it in the roadmap... If enough people think it's a nice idea someone might even contribute to it...
11:44 < lemoinem> I would myself but I don't have the necessary free time on my hands right now )':
11:46 < lemoinem> (per-host ssh command might happen to be useful too in some weird cases...)
11:50 < lemoinem> Oh, another one, having a way to configure the command mosh-server is running (could be useful to have run tmux/screen instead of a direct login shell), but I have a work-around for that already and it's a different feature.
11:50 < joneskoo> basically the reason why config file has not been implemented are security concerns
11:51 < lemoinem> ? security concerns, how come?
11:51 < joneskoo> the current behaviour is simple

lemoinem commented May 29, 2013

FTR, IRC discussion:

11:40 < lemoinem> I was wondering if there has already been a discussion regarding a .ssh/config-like file for mosh...
11:41 < grawity> What options would it have?
11:41 < lemoinem> I think it's a kind of small feature code-wise that would go a great way to improve the usability.
11:41 < lemoinem> On the top of my head, port is the one I see the most usefull
11:41 < achin> -p is the only useful option to mosh, right?
11:41 < lemoinem> yeah, but mosh-server could be too
11:41 < achin> true
11:42 < achin> in the past, people have recommended aliases for this, but i can see how a .mosh-config might be useful
11:42 < lemoinem> (plus, with oob data coming with mosh 1.3 (iirc), we could enable/disable it on a per-host basis...)
11:44 < lemoinem> otoh, I understand it might still be a bit of work code-wise, but I guess it would already be nice to have it in the roadmap... If enough people think it's a nice idea someone might even contribute to it...
11:44 < lemoinem> I would myself but I don't have the necessary free time on my hands right now )':
11:46 < lemoinem> (per-host ssh command might happen to be useful too in some weird cases...)
11:50 < lemoinem> Oh, another one, having a way to configure the command mosh-server is running (could be useful to have run tmux/screen instead of a direct login shell), but I have a work-around for that already and it's a different feature.
11:50 < joneskoo> basically the reason why config file has not been implemented are security concerns
11:51 < lemoinem> ? security concerns, how come?
11:51 < joneskoo> the current behaviour is simple

@sekrause

This comment has been minimized.

Show comment
Hide comment
@sekrause

sekrause Jun 18, 2013

At least for the port I think a server-side configuration file would be much better. Just like SSH has its ~/.ssh/authorized_keys for the user's key we could have a ~/.mosh/ports which defines the ports mosh is allowed to use.

For example if my sysadmin has opened up the UDP port 63210 so that I can use mosh, I simply type echo 63210 >> ~/.mosh/ports (it could also be a port range) and mosh-server will no longer user the ports 60000-61000, but the one defined in the server's configuration file.

sekrause commented Jun 18, 2013

At least for the port I think a server-side configuration file would be much better. Just like SSH has its ~/.ssh/authorized_keys for the user's key we could have a ~/.mosh/ports which defines the ports mosh is allowed to use.

For example if my sysadmin has opened up the UDP port 63210 so that I can use mosh, I simply type echo 63210 >> ~/.mosh/ports (it could also be a port range) and mosh-server will no longer user the ports 60000-61000, but the one defined in the server's configuration file.

@lemoinem

This comment has been minimized.

Show comment
Hide comment
@lemoinem

lemoinem Jun 18, 2013

I'm not sure about having a config file for a single config avery good idea... I think it will tend to multiply the number of config files rather quickly if we ever want other configurations server-side. However, the idea of configuring the port server-side is actually a very good point (👍), and could even be configured in a system-wide configuration file.

However, I think it would still be useful to be able to override this client-side in some special cases (SSH Tunnel to reach a FWed host, multiple FW with port translating between the client and the server, etc.

lemoinem commented Jun 18, 2013

I'm not sure about having a config file for a single config avery good idea... I think it will tend to multiply the number of config files rather quickly if we ever want other configurations server-side. However, the idea of configuring the port server-side is actually a very good point (👍), and could even be configured in a system-wide configuration file.

However, I think it would still be useful to be able to override this client-side in some special cases (SSH Tunnel to reach a FWed host, multiple FW with port translating between the client and the server, etc.

@jgillman

This comment has been minimized.

Show comment
Hide comment
@jgillman

jgillman Oct 1, 2013

I'm a little late to the party here, but +1 for a config file.

To connect to my home server I have to type: mosh -p 12345 --ssh="ssh -p 54321 -i ./.ssh/id_rsa" my.host.name

Yes, I can easily alias that but being able to store those the way I would for ssh would be very useful as my config would become more portable. As far as security concerns, I don't see how it would be any less secure than using a .ssh/config file. Plus, it's optional.

jgillman commented Oct 1, 2013

I'm a little late to the party here, but +1 for a config file.

To connect to my home server I have to type: mosh -p 12345 --ssh="ssh -p 54321 -i ./.ssh/id_rsa" my.host.name

Yes, I can easily alias that but being able to store those the way I would for ssh would be very useful as my config would become more portable. As far as security concerns, I don't see how it would be any less secure than using a .ssh/config file. Plus, it's optional.

@andersk

This comment has been minimized.

Show comment
Hide comment
@andersk

andersk Oct 1, 2013

Member

mosh already respects SSH options stored in ~/.ssh/config, so there’s no need to pass a long --ssh option every time:

Host my.host.name
    Port 54321
    IdentityFile ~/.ssh/id_rsa
Member

andersk commented Oct 1, 2013

mosh already respects SSH options stored in ~/.ssh/config, so there’s no need to pass a long --ssh option every time:

Host my.host.name
    Port 54321
    IdentityFile ~/.ssh/id_rsa
@jgillman

This comment has been minimized.

Show comment
Hide comment
@jgillman

jgillman Oct 2, 2013

@andersk So it does! I don't know why I didn't try that. Thanks for the tip :)

jgillman commented Oct 2, 2013

@andersk So it does! I don't know why I didn't try that. Thanks for the tip :)

@promolic1

This comment has been minimized.

Show comment
Hide comment
@promolic1

promolic1 Jan 19, 2014

Bumping this issue.

I already know as @andersk said, mosh uses the ssh config file. But what about a custom UDP port? Any workaround to avoid remembering/writing the desired port per host?

promolic1 commented Jan 19, 2014

Bumping this issue.

I already know as @andersk said, mosh uses the ssh config file. But what about a custom UDP port? Any workaround to avoid remembering/writing the desired port per host?

@kiniou

This comment has been minimized.

Show comment
Hide comment
@kiniou

kiniou Jan 27, 2014

Hi,

I did a simple python3 scripting that does enable profile for mosh ports and commands. It can be found at https://github.com/kiniou/moshy .

kiniou commented Jan 27, 2014

Hi,

I did a simple python3 scripting that does enable profile for mosh ports and commands. It can be found at https://github.com/kiniou/moshy .

earlchew added a commit to earlchew/mosh that referenced this issue Feb 9, 2014

[mosh] Add configuration file parsing
mobile-shell#431

Add class ConfigFile that is based on ssh_config(5) and have it parse
~/.mosh/config that will be used to store global and per-host configuration.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Feb 9, 2014

[mosh] Use --test to trigger configuration unit test
mobile-shell#431

Add undocumented --test option that will trigger the unit test in
the ConfigFile class.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Feb 9, 2014

[mosh] Refactor fake_proxy to simplify configuration file processing
mobile-shell#431

Move fake_proxy to before the main option processing to simplify
configuration file processing.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Feb 9, 2014

[mosh] Perform command line initialisation as early as possible
mobile-shell#431

Move command line initialisation before considering any of the command line
options to simplify subsequent configuration file operations.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Feb 9, 2014

[mosh] Initialize options only if not provided on the command line
mobile-shell#431

Declare option variables as undef, and only provide a default value
if options were not provided on the command line in preparation for
obtaining values from a configuration file.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Feb 9, 2014

[mosh] Use entries from the configuration file
mobile-shell#431

Initialize options from the configuration file if not present on the
command line.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
@pjrobertson

This comment has been minimized.

Show comment
Hide comment
@pjrobertson

pjrobertson Feb 28, 2014

Looks like this is in the pipeline!
+1 for this feature.

Currently I have to do

mosh --server=/home/user/bin/mosh-server me@domain.com

It would be nice to not have to specify --server :)

pjrobertson commented Feb 28, 2014

Looks like this is in the pipeline!
+1 for this feature.

Currently I have to do

mosh --server=/home/user/bin/mosh-server me@domain.com

It would be nice to not have to specify --server :)

@ekacnet

This comment has been minimized.

Show comment
Hide comment
@ekacnet

ekacnet Nov 26, 2014

I did something that works well in my branch config: https://github.com/ekacnet/mosh/tree/config

I made a pull request but so far it seems that it hasn't been pulled.

ekacnet commented Nov 26, 2014

I did something that works well in my branch config: https://github.com/ekacnet/mosh/tree/config

I made a pull request but so far it seems that it hasn't been pulled.

@infinity0

This comment has been minimized.

Show comment
Hide comment
@infinity0

infinity0 Oct 30, 2015

Instead of having a separate .moshrc, it would be easier for users, to just put these extra options in .ssh/config?

Host xxx.com.yyy
HostName xxx.com
User uuu
MoshPort 6nnn
MoshPrediction always

infinity0 commented Oct 30, 2015

Instead of having a separate .moshrc, it would be easier for users, to just put these extra options in .ssh/config?

Host xxx.com.yyy
HostName xxx.com
User uuu
MoshPort 6nnn
MoshPrediction always
@andersk

This comment has been minimized.

Show comment
Hide comment
@andersk

andersk Oct 30, 2015

Member

@infinity0, nope, the unrecognized syntax would completely break ssh (and therefore also mosh). I could imagine putting them inside magic comments…but not for two seconds longer than I have to.

Member

andersk commented Oct 30, 2015

@infinity0, nope, the unrecognized syntax would completely break ssh (and therefore also mosh). I could imagine putting them inside magic comments…but not for two seconds longer than I have to.

@emtiu

This comment has been minimized.

Show comment
Hide comment
@emtiu

emtiu Mar 13, 2016

Any consensus on this in sight? I'm also very much interested in server-side custom port(range)s. Don't mind if it's systemwide (as in /etc/moshports) or per-user (as in ~/.moshports).

emtiu commented Mar 13, 2016

Any consensus on this in sight? I'm also very much interested in server-side custom port(range)s. Don't mind if it's systemwide (as in /etc/moshports) or per-user (as in ~/.moshports).

@Toub

This comment has been minimized.

Show comment
Hide comment
@Toub

Toub Mar 16, 2016

Also interested to have a client-side or server-side configuration for udp port range.

Toub commented Mar 16, 2016

Also interested to have a client-side or server-side configuration for udp port range.

@rgruesbeck

This comment has been minimized.

Show comment
Hide comment
@rgruesbeck

rgruesbeck May 6, 2016

+1 for this

rgruesbeck commented May 6, 2016

+1 for this

@Myke

This comment has been minimized.

Show comment
Hide comment
@Myke

Myke May 14, 2016

Another vote for server-side config; with multiple servers behind NAT, ssh-config nicely solves the port changes, but there's no elegant way to teach mosh that it's only getting specific ports forwarded to it.

Myke commented May 14, 2016

Another vote for server-side config; with multiple servers behind NAT, ssh-config nicely solves the port changes, but there's no elegant way to teach mosh that it's only getting specific ports forwarded to it.

@yookoala

This comment has been minimized.

Show comment
Hide comment
@yookoala

yookoala Jul 3, 2016

+1

There is no way to config custom mosh-server udp port range now.
Would be really handy if a config file is available.

yookoala commented Jul 3, 2016

+1

There is no way to config custom mosh-server udp port range now.
Would be really handy if a config file is available.

@tjanson

This comment has been minimized.

Show comment
Hide comment
@tjanson

tjanson Jul 3, 2016

Please refrain from "+1-ing" issues, here or elsewhere. I’m sure you mean well, but it dilutes the discussion and essentially spams subscribers of the issue.

tjanson commented Jul 3, 2016

Please refrain from "+1-ing" issues, here or elsewhere. I’m sure you mean well, but it dilutes the discussion and essentially spams subscribers of the issue.

@skmlcd

This comment has been minimized.

Show comment
Hide comment
@skmlcd

skmlcd Nov 20, 2016

Great idea, but please avoid polluting home directory, refer to XDG base directory spec.

skmlcd commented Nov 20, 2016

Great idea, but please avoid polluting home directory, refer to XDG base directory spec.

@eminence eminence added the feature label Sep 14, 2017

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Add configuration file parsing
mobile-shell#431

Add class ConfigFile that is based on ssh_config(5) and have it parse
~/.mosh/config that will be used to store global and per-host configuration.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Use --test to trigger configuration unit test
mobile-shell#431

Add undocumented --test option that will trigger the unit test in
the ConfigFile class.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Refactor fake_proxy to simplify configuration file processing
mobile-shell#431

Move fake_proxy to before the main option processing to simplify
configuration file processing.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Perform command line initialisation as early as possible
mobile-shell#431

Move command line initialisation before considering any of the command line
options to simplify subsequent configuration file operations.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Initialize options only if not provided on the command line
mobile-shell#431

Declare option variables as undef, and only provide a default value
if options were not provided on the command line in preparation for
obtaining values from a configuration file.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Use entries from the configuration file
mobile-shell#431

Initialize options from the configuration file if not present on the
command line.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Add configuration file parsing
mobile-shell#431

Add class ConfigFile that is based on ssh_config(5) and have it parse
~/.mosh/config that will be used to store global and per-host configuration.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Use --test to trigger configuration unit test
mobile-shell#431

Add undocumented --test option that will trigger the unit test in
the ConfigFile class.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Refactor fake_proxy to simplify configuration file processing
mobile-shell#431

Move fake_proxy to before the main option processing to simplify
configuration file processing.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Perform command line initialisation as early as possible
mobile-shell#431

Move command line initialisation before considering any of the command line
options to simplify subsequent configuration file operations.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Initialize options only if not provided on the command line
mobile-shell#431

Declare option variables as undef, and only provide a default value
if options were not provided on the command line in preparation for
obtaining values from a configuration file.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Dec 10, 2017

[mosh] Use entries from the configuration file
mobile-shell#431

Initialize options from the configuration file if not present on the
command line.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
@dpsenner

This comment has been minimized.

Show comment
Hide comment
@dpsenner

dpsenner Mar 7, 2018

Is there a plan when this feature might be released?

dpsenner commented Mar 7, 2018

Is there a plan when this feature might be released?

earlchew added a commit to earlchew/mosh that referenced this issue Apr 5, 2018

[mosh] Add configuration file parsing
mobile-shell#431

Add class ConfigFile that is based on ssh_config(5) and have it parse
~/.mosh/config that will be used to store global and per-host configuration.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 5, 2018

[mosh] Use --test to trigger configuration unit test
mobile-shell#431

Add undocumented --test option that will trigger the unit test in
the ConfigFile class.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 5, 2018

[mosh] Refactor fake_proxy to simplify configuration file processing
mobile-shell#431

Move fake_proxy to before the main option processing to simplify
configuration file processing.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 5, 2018

[mosh] Perform command line initialisation as early as possible
mobile-shell#431

Move command line initialisation before considering any of the command line
options to simplify subsequent configuration file operations.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 5, 2018

[mosh] Initialize options only if not provided on the command line
mobile-shell#431

Declare option variables as undef, and only provide a default value
if options were not provided on the command line in preparation for
obtaining values from a configuration file.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 5, 2018

[mosh] Use entries from the configuration file
mobile-shell#431

Initialize options from the configuration file if not present on the
command line.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 7, 2018

[mosh] Add configuration file parsing
mobile-shell#431

Add class ConfigFile that is based on ssh_config(5) and have it parse
~/.mosh/config that will be used to store global and per-host configuration.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 7, 2018

[mosh] Use --test to trigger configuration unit test
mobile-shell#431

Add undocumented --test option that will trigger the unit test in
the ConfigFile class.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 7, 2018

[mosh] Refactor fake_proxy to simplify configuration file processing
mobile-shell#431

Move fake_proxy to before the main option processing to simplify
configuration file processing.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 7, 2018

[mosh] Perform command line initialisation as early as possible
mobile-shell#431

Move command line initialisation before considering any of the command line
options to simplify subsequent configuration file operations.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 7, 2018

[mosh] Initialize options only if not provided on the command line
mobile-shell#431

Declare option variables as undef, and only provide a default value
if options were not provided on the command line in preparation for
obtaining values from a configuration file.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 7, 2018

[mosh] Use entries from the configuration file
mobile-shell#431

Initialize options from the configuration file if not present on the
command line.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>

earlchew added a commit to earlchew/mosh that referenced this issue Apr 7, 2018

[mosh] Initialize $forward_agent only if not provided on the command …
…line

mobile-shell#431

Declare $forward_agent as undef, and only provide a default value
if options were not provided on the command line in preparation for
obtaining values from a configuration file.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment