-
Notifications
You must be signed in to change notification settings - Fork 749
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
Comments
FTR, IRC discussion:
|
At least for the port I think a server-side configuration file would be much better. Just like SSH has its For example if my sysadmin has opened up the UDP port 63210 so that I can use mosh, I simply type |
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 (:+1:), 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. |
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: 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 |
mosh already respects SSH options stored in
|
@andersk So it does! I don't know why I didn't try that. Thanks for the tip :) |
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? |
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 . |
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 <[email protected]>
mobile-shell#431 Add undocumented --test option that will trigger the unit test in the ConfigFile class. Signed-off-by: Earl Chew <[email protected]>
mobile-shell#431 Move fake_proxy to before the main option processing to simplify configuration file processing. Signed-off-by: Earl Chew <[email protected]>
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 <[email protected]>
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 <[email protected]>
mobile-shell#431 Initialize options from the configuration file if not present on the command line. Signed-off-by: Earl Chew <[email protected]>
Looks like this is in the pipeline! Currently I have to do
It would be nice to not have to specify |
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. |
Instead of having a separate
|
@infinity0, nope, the unrecognized syntax would completely break |
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). |
Also interested to have a client-side or server-side configuration for udp port range. |
+1 for this |
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. |
+1 There is no way to config custom mosh-server udp port range now. |
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. |
Great idea, but please avoid polluting home directory, refer to XDG base directory spec. |
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 <[email protected]>
mobile-shell#431 Add undocumented --test option that will trigger the unit test in the ConfigFile class. Signed-off-by: Earl Chew <[email protected]>
mobile-shell#431 Initialize options from the configuration file if not present on the command line. Signed-off-by: Earl Chew <[email protected]>
Is there a plan when this feature might be released? |
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 <[email protected]>
mobile-shell#431 Add undocumented --test option that will trigger the unit test in the ConfigFile class. Signed-off-by: Earl Chew <[email protected]>
mobile-shell#431 Move fake_proxy to before the main option processing to simplify configuration file processing. Signed-off-by: Earl Chew <[email protected]>
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 <[email protected]>
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 <[email protected]>
mobile-shell#431 Initialize options from the configuration file if not present on the command line. Signed-off-by: Earl Chew <[email protected]>
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 <[email protected]>
mobile-shell#431 Add undocumented --test option that will trigger the unit test in the ConfigFile class. Signed-off-by: Earl Chew <[email protected]>
mobile-shell#431 Move fake_proxy to before the main option processing to simplify configuration file processing. Signed-off-by: Earl Chew <[email protected]>
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 <[email protected]>
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 <[email protected]>
mobile-shell#431 Initialize options from the configuration file if not present on the command line. Signed-off-by: Earl Chew <[email protected]>
…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 <[email protected]>
I know this is an old ticket, but I've noticed that it's still open. Could you provide some guidance as to whether this is still in the works? I have several machines running mosh behind NAT and it would be fantastic if I could configure them server side to use a specified port range. |
Bump. Since the server is already responsible for selecting a port, it makes a lot of sense for there to be a config option to pin this port choice. I have several servers behind a common gateway, and currently I have to remember each of their UDP port mapping which is a pain in the arse. Hopefully this feature gets released soon. |
Can we just have mosh parse the ports from ~/.ssh/config? I already have all my hosts setup with the ports the require but mosh seems to ignore this and simple tries to connect to the default ports. Is this a bug or a design limitation? I can't see mosh being very useful if I need to remember and type in long string with UPD ports for every server. |
mosh uses ssh to initiate it's own service. In this phase, mosh uses your |
Mosh does respect The difference is, mosh only uses the SSH profile during initial establishment of contact. Then mosh set up its own UDP server listening on another port (completely unrelated to SSH, and this is the port we want a config for), and tells the client to contact it over there. Kind of like how ATC handles switchovers in the aviation industry. It is obvious then why settings for this mosh UDP server should belong in its own config file. Hopefully this lets you understand how mosh works a little bit better. |
I just wish mosh would use a more of the directives within the aliases in |
@cyqsimon The work around that I use to set the mosh ports is to use a wrapper script to set the ports based on the hostname. I use the fish shell and I use a fish shell function for this. You could also make a bash wrapper script but name it something different like, 'start-mosh'. Here is a sanitized version of the fish function: # Defined in /home/username/.config/fish/functions/mosh.fish @ line 1
function mosh --description 'mosh wrapper to setup special command line option for hosts that we do not want to type or remember each time.'
set sshhostname $argv[1]
set -e argv[1]
switch $sshhostname
case example.com
set runoptions -p 60077 --port 60077:60086
case example.org
set runoptions -p 60088 --port 60088:60096
case '*'
end
set_color yellow
echo -n "Now running: "
set_color blue
echo /usr/bin/mosh $runoptions $argv $sshhostname
set_color normal
echo ""
/usr/bin/mosh $runoptions $argv $sshhostname
end I hope that someone finds this workaround helpful. |
tl;drNeed to enter port manually each time? -> RTFM ;) Long version:I do have multiple servers worldwide at different operators. One of them does an external Firewalling outside of the usual linux VM firewall. So with a proper ssh config file, while for other servers I simply tpye From former info I have had from the command line output which reads: The FAQ already states that:
So for all that have still problems with this: Still, having the port range configurable on the server side would be nice, just to match the firewall of the server for unknowing users, but I could solve my problem in another way. |
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
, eventuallyssh
andcommand
(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.
The text was updated successfully, but these errors were encountered: