-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Generate an updated ~/.ssh/config when using "advanced" regex in hostnames #122
Comments
I'm not too fond of the wrapper idea for a few reasons
I have tried (and seen others) make shell functions to replace ssh but that can get ugly depending on complexity, version of bash, version of ssh, etc. IMO a function is more maintainable than a separate external script that needs to be loaded in $PATH. It also gets hard when people use different shells and if they keep their own .dotfiles repo for configuration. Also not sure about parsing ~/.ssh/known-hosts. In some situations that file can be very large. I often have hundreds of hosts in mine. Would you also parse /etc/ssh/ssh_known_hosts? In that case the file on my system changes regularly (every ~30 minutes) via config management and has many thousands of entries. Why not have assh expand the advanced regex into .ssh/config so they are individual entries. Maybe that would expand to a lot (depending on the regex) for for some cases (eg. host[0-9]) it wouldn't be very hard. As a side note, why is using mosh as a default command a bad idea? I'm assuming because not all flags are compatible with ssh but thought I'd ask. I was going to open an issue for allowing mosh to be used as default instead of ssh depending on what network I'm on. eg. connected via wifi or 3g use mosh instead of ssh but that's probably best for a shell function. Default commands are probably best to be left to the shell post login. There is too much logic that may need to be considered. |
Thank you @rothgar for your feedback 🎁 !
👍 for also providing just a *sh function or an alias that people can keep in their own .dotfiles
Yes, as an alternative, I can build my own
I like the idea, we need to find a regex expander to give some tries and estimate how big would become a
I just opened #129, to discuss about this subject
I think this feature makes sense, especially as I'm using Docker on a daily basis, now I love to have "images" that have a default behavior which can super-easily be bypass by specifying a command instead of not providing one. |
Context
Today, assh will generate an
Host
entry in the~/.ssh/config
for:vm-5
match
):vm-*
vm-[0-9]
So basically, assh knows how to proxy to an host, but all options except
Host
won't be written to~/.ssh/config
.So there will be absolutely no entry in the
~/.ssh/config
file if we callssh vm-5
, and all options exceptHost
will be lost;Port
will fallback to 22,IdentifyFile
will use the global value, etc.2 dummy solutions would be:
~/.ssh/config
file, so if you putvm-[0-9]
, I will generatevm-*
: this will work for basic regex but it will fails as soon as you have advanced regex, i.e an entry withvm-[0-4]
, and another entry withvm-[5-9]
.-p 22
manually or if the%p=22
is the default value. This solution will works forPort
, but it won't let you use non-network related ssh option, asIdentityFile
for instance.One more promising solution is to a wrapper around ssh that will rebuild the
~/.ssh/config
file if it detects an advanced regex in the current host.The wrapper will just check if
~/.ssh/config
needs to be rebuild before running the realssh
binary.This wrapper won't be configurable everywhere outside of the command-line, for example a GUI program may use an hardcoded
/usr/bin/ssh
.For this specific case, the solution is to call the ssh 2 times; One time to generate the
~/.ssh/config
file and fail, and a second time to connect using the updated file.The good point, is that this wrapper will stay optional and will only improve the use of
assh
in advanced cases.Todo:
ssh
,scp
, .../usr/bin/ssh
~/.ssh/known-hosts
and generate~/.ssh/config
entries for all the known hostsassh proxy
needs to continue to build the~/.ssh/config
file when usingassh
without the wrapper and needs to bypass this step when using the wrapper (the wrapper will do this step before callingssh
)assh
telling ifssh
is wrapped or not (for debugging)I'm eager to have this wrapper finished, it will ease a lot the creation of new unique features 🍻 !
Some ideas:
support raw password input (using
pexpect
)use alternate ssh binary depending on the
assh.yml
configuration:configure custom environment variables
equivalent of https://github.com/icefox/git-achievements for ssh
dynamically create a new ssh RSA key per new host
support a default command to run
automatically reconnect
automatically call
ssh-copy-id
on new hostssupport
assh
options directly in the command linesshrc-like features
Related with #121, #39, #41, #127
The text was updated successfully, but these errors were encountered: