Skip to main content

A ssh config generator I dont recommend to use

Project description

My ssh config is hell. Even if its not much, its hell. I have ~190 host entries which results in 1094(!) lines of sshconfig. Which I maintain manually. Man-u-a-ll-y!

Why is that?

I use a lot of aliases to remember all my hosts. Which is probably my fault but im used to it. A typical entry looked like

Host drap21 pdrap21
  User myuser
  Port 22
  IdentiyFile ~/.ssh/project_id_rsa

You can do a lot of stuff with wildcards in sshconfig. What you cant do is having dynamic aliases (at least what I know). This would require a templating like option.

And thats why i wrote this tiny script.

install & usage

as usual.

pip install sadcat
sadcat ~/.ssh/sadcat.toml

Personally i use two aliases

# set refresh alias
alias sshre="$SADCAT $HOME/.ssh/sadcat.toml > $HOME/.ssh/config"

# set edit alias
alias sshedit="$EDITOR $HOME/.ssh/sadcat.toml"



A minimal config would look like this.


hostname = "nyc-dpzzt[01-03]"

and sadcat generates 3 ssh entries for you called nyc-dpzzt01, nyc-dpzzt02 and nyc-dpzzt03. Simple.


To save more lines you can apply a template to a hosts group


hostname = "fra1024mfoo[001-005]"
template = "fra1024"


user = "otheruser"
port = "2202"

Of course, setting a variable in hosts will always overwrite those being set in templates.

There is a special template that is applied to every host if its configured called “default”. ([templates.default])


those can be specified in hosts using a toml array if multiple or a string. Range numbers (if available) will be applied at the end. Thats just how i like it. Theres no deeper meaning.

hostname = "nyc-dpzzt[5-9]"
template = "company"
alias = [ "dypppt", "dzzzpt" ]

would result in

Host nyc-dpzzt5 dypppt5 dzzzpt5
  hostname ...

Host nyc-dpzzt6 dypppt6 dzzzpt6
  hostname ...

but as said, alias can also be just a string

hostname = "nyc-dpzzt[5-9]"
alias = "dypppt"

single hosts

As you might expected, if you dont have a Range defined in a hostname this entry will result in one single host.

hostname = "fra1024mfoo23"
user = "foo"


If all that is still not enough flexibility, you can add custom snippets to your ssh config by defining multiline strings in the [custom] section with full hosts.


hostsb = '''

  hostname bla
  user foo

  hostname foo
  user bar
  port par

strangehost = '''

Host baz
  hostname baz
  port 666
  user evil

For more detailed examples see conf.toml in this repo.


I used a project name generator and liked it.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sadcat-3.0.0.tar.gz (5.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page