You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It’s not THAT much trouble to update your .ssh/config file every time a host changes, but when it starts happening often enough, even that hassle starts to add up. This is a quick tool I wrote to help handle them.
It takes great care to not trash your config file, so you can continue to edit your config files by hand before and after running the tool.
ssh-config will make a backup of your ~/.ssh/config file as ~/.ssh/config~.
Probably the most useful command is “copy”, which intelligently copies an existing host section.
Copies the entire section named <old_host> to a new section called <new_host>. If old_host has a Hostname section, ssh-config will try to update it to reflect the new_host name. For example, if you had a section like
Hostrails01Hostnamerails01.example.com
And you did ssh-config copy rails01 rails02, the new section would look like this:
Hostrails02Hostnamerails02.example.com
You can manually override any setting, and/or set new ones by appending the new key/value pairs at the end. Given the rails01 section above, “ssh-config copy rails01 rails02 Hostname rails-02.example.com User dbrady” would emit
Hostrails02Hostnamerails-02.example.comUserdbrady
Note: If you just want another short name for a host, use alias instead
With 2 or more arguments, looks up host by <host> (must be the first name on the Host line), and removes any <alias>es from the list of alternate names. With only 1 argument, looks for an entry by that alias (must NOT be the first name on the Host line), and removes the alias from the entry, if found.