Skip to content

Commit 6a5dda4

Browse files
committed
docs: update usage and output example
1 parent c20477a commit 6a5dda4

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

README.md

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Current version: v0.5.0
2323

2424
## Features
2525

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).
2727
2. Custom configuration for ssh-agent.
2828
3. Custom SSH aliases for quick connections.
2929
4. Skip selected hosts from results file.
@@ -125,7 +125,8 @@ SSHGEN_DEBUG=1 sshgen generate
125125
After executing the command, you will see the following output:
126126

127127
```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
129130
```
130131

131132
Check the file contents `cat /my_dir/config`:
@@ -151,37 +152,52 @@ Host host4 postgres-server # group2
151152
IdentityAgent ~/.1password/agent.sock
152153
```
153154

154-
If you ran using verbose mode, you should see additional information:
155+
If you run using verbose mode, you should see additional information:
155156

156157
<details><summary>Verbose output example</summary>
157158
<p>
158159

159160
```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
179182
```
180183

181184
</p>
182185
</details>
183186

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:
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
185201
into the corresponding hosts. For example, running `ssh base` will connect you to the host with the IP address 127.0.0.1
186202
as the root user and utilizing 1password as your SSH agent.
187203

0 commit comments

Comments
 (0)