@@ -23,7 +23,7 @@ Current version: v0.5.0
23
23
24
24
## Features
25
25
26
- 1 . Generates a ` config ` file to merge with your existing SSH configuration.
26
+ 1 . Generates a ` config ` file to merge with your existing SSH configuration or include as a separate ` .conf ` file (since v0.6.0) .
27
27
2 . Custom configuration for ssh-agent.
28
28
3 . Custom SSH aliases for quick connections.
29
29
4 . Skip selected hosts from results file.
@@ -125,7 +125,8 @@ SSHGEN_DEBUG=1 sshgen generate
125
125
After executing the command, you will see the following output :
126
126
127
127
` ` ` text
128
- [INFO] - Generated SSH config file was saved to /my_dir/config
128
+ [2024-03-10 10:00:00] [INFO] - Generated SSH config file was saved to /my_dir/config
129
+ [2024-03-10 10:00:00] [INFO] - Total processed hosts: 3, total skipped hosts: 1
129
130
` ` `
130
131
131
132
Check the file contents `cat /my_dir/config` :
@@ -151,37 +152,52 @@ Host host4 postgres-server # group2
151
152
IdentityAgent ~/.1password/agent.sock
152
153
` ` `
153
154
154
- If you ran using verbose mode, you should see additional information :
155
+ If you run using verbose mode, you should see additional information :
155
156
156
157
<details><summary>Verbose output example</summary>
157
158
<p>
158
159
159
160
` ` ` text
160
- [2023-10-21 17:53:31] [DEBUG] - Loading ansible hosts file: /home/user/code/python/sshgen/examples/hosts.yml
161
- [2023-10-21 17:53:31] [DEBUG] - Total hosts found (include skipped): 4
162
- [2023-10-21 17:53:31] [DEBUG] - Using template file /home/user/code/python/sshgen/sshgen/templates/ssh_config.template to generate ssh config
163
- [2023-10-21 17:53:31] [DEBUG] - Filtering hosts where _skip metafield was defined
164
- [2023-10-21 17:53:31] [DEBUG] - Host host1 should be skipped: False
165
- [2023-10-21 17:53:31] [DEBUG] - Host host2 should be skipped: True
166
- [2023-10-21 17:53:31] [DEBUG] - Host host3 should be skipped: False
167
- [2023-10-21 17:53:31] [DEBUG] - Host host4 should be skipped: False
168
- [2023-10-21 17:53:31] [DEBUG] - Processing host1 from group group1
169
- [2023-10-21 17:53:31] [DEBUG] - Adding SSH port 22 for host host1
170
- [2023-10-21 17:53:31] [DEBUG] - Adding aliases ['base', 'another-alias'] for host host1
171
- [2023-10-21 17:53:31] [DEBUG] - Adding custom auth methods for host host1
172
- [2023-10-21 17:53:31] [DEBUG] - Processing host3 from group group2
173
- [2023-10-21 17:53:31] [DEBUG] - Adding SSH port 19222 for host host3
174
- [2023-10-21 17:53:31] [DEBUG] - Processing host4 from group group2
175
- [2023-10-21 17:53:31] [DEBUG] - Adding SSH port 22 for host host4
176
- [2023-10-21 17:53:31] [DEBUG] - Adding aliases ['postgres-server'] for host host4
177
- [2023-10-21 17:53:31] [DEBUG] - Adding custom auth methods for host host4
178
- [2023-10-21 17:53:31] [INFO] - Generated SSH config file was saved to /home/user/code/python/sshgen/config
161
+ [2024-03-10 10:00:00] [DEBUG] - Loading ansible hosts file: /home/user/code/python/sshgen/examples/hosts.yml
162
+ [2024-03-10 10:00:00] [DEBUG] - Total hosts found (include skipped): 4
163
+ [2024-03-10 10:00:00] [DEBUG] - Using template file /home/user/code/python/sshgen/sshgen/templates/ssh_config.template to generate ssh config
164
+ [2024-03-10 10:00:00] [DEBUG] - Filtering hosts where _skip metafield was defined
165
+ [2024-03-10 10:00:00] [DEBUG] - Host host1 should be skipped: False
166
+ [2024-03-10 10:00:00] [DEBUG] - Host host2 should be skipped: True
167
+ [2024-03-10 10:00:00] [DEBUG] - Host host3 should be skipped: False
168
+ [2024-03-10 10:00:00] [DEBUG] - Host host4 should be skipped: False
169
+ [2024-03-10 10:00:00] [DEBUG] - Processing host1 from group group1
170
+ [2024-03-10 10:00:00] [DEBUG] - Adding SSH port 22 for host host1
171
+ [2024-03-10 10:00:00] [DEBUG] - Adding aliases ['base', 'another-alias'] for host host1
172
+ [2024-03-10 10:00:00] [DEBUG] - Adding custom auth methods for host host1
173
+ [2024-03-10 10:00:00] [DEBUG] - Processing host3 from group group2
174
+ [2024-03-10 10:00:00] [DEBUG] - Adding SSH port 19222 for host host3
175
+ [2024-03-10 10:00:00] [DEBUG] - Processing host4 from group group2
176
+ [2024-03-10 10:00:00] [DEBUG] - Adding SSH port 22 for host host4
177
+ [2024-03-10 10:00:00] [DEBUG] - Adding aliases ['base', 'another-alias'] for host host4
178
+ [2024-03-10 10:00:00] [DEBUG] - Adding custom auth methods for host host4
179
+ [2024-03-10 10:00:00] [INFO] - Generated SSH config file was saved to /home/user/code/python/sshgen/config
180
+ [2024-03-10 10:00:00] [DEBUG] - Skipped hosts list: 127.0.0.2
181
+ [2024-03-10 10:00:00] [INFO] - Total processed hosts: 3, total skipped hosts: 1
179
182
` ` `
180
183
181
184
</p>
182
185
</details>
183
186
184
- Copy and insert the output into your `~/.ssh/config` file. After that, you can use any of the defined aliases to SSH
187
+ There are two ways to use the generated file :
188
+ 1. Copy and insert the output into your `~/.ssh/config` file.
189
+ 2. Copy file to the conf directory, e.g. `~/.ssh/config.d/00-custom.conf` (if it's not exist, create one).
190
+ Edit your `~/.ssh/config` and add `Include` directive **to the top** :
191
+
192
+ ` ` `
193
+ #### Custom configuration
194
+
195
+ Include ~/.ssh/config.d/*.conf
196
+
197
+ #### End of custom configuration
198
+ ` ` `
199
+
200
+ After that, you can use any of the defined aliases to SSH
185
201
into the corresponding hosts. For example, running `ssh base` will connect you to the host with the IP address 127.0.0.1
186
202
as the root user and utilizing 1password as your SSH agent.
187
203
0 commit comments