Generate SSH config from Salt server lists
- Python 3.9+
It's your servers.sls
file:
servers:
lab-1001:
main_ip: 1.2.3.4
...
...
lab-1002:
main_ip: 4.5.6.7
...
...
...
...
Note: Add/remove extra info from
main.py
file. For exampleIdentityFile
,IdentityAgent
, etc
Run:
python main.py <servers.sls> <output> <ssh port> <ssh user> <mode>
python main.py /Salt/pillar/dev/servers.sls out.txt 22 arash Staging
#------- Staging Servers ------#
Host lab-1001
HostName 1.2.3.4
Port 22
User user
IdentitiesOnly yes
IdentityAgent ~/.gnupg/S.gpg-agent.ssh
IdentityFile ~/.ssh/id_rsa_yubikey.pub
Host lab-1002
HostName 4.5.6.7
Port 22
User user
IdentitiesOnly yes
IdentityAgent ~/.gnupg/S.gpg-agent.ssh
IdentityFile ~/.ssh/id_rsa_yubikey.pub
Also you will have two another files:
- A
ip-list.json
file containing all IPs will be generated for further use. - A
server-list.json
file containing all servers with their IP based onrole
,zone
,provider
andcode
. There is another
key for unknown servers. You can Change__create_list()
function to fit your needs. - A
server-list.toml
file to use with WireGuard-Config-Generator