Skip to content

Commit 848fac8

Browse files
committed
Final paths, LICENSE, README
1 parent 2432a9c commit 848fac8

5 files changed

Lines changed: 104 additions & 7 deletions

File tree

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Ben Cromwell
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# sshush
2+
3+
Takes a YAML defined set of SSH configs and produces an SSH config file from it.
4+
5+
Defaults to `~/.ssh/config.yml` for the source and `~/.ssh/config` for the destination.
6+
7+
#### Premise
8+
9+
I wanted a way to manage my SSH config file that allowed me to define an inheritance based structure. This allows you to group hosts together, apply common options and be able to override the options if needs be. For example, maybe you have everything in DigitalOcean on a particular port with a particular user and SSH key, but everything in AWS is different. Or they share ports but not keys.
10+
11+
#### Globals
12+
13+
Options that apply to the catch-all `Host *`.
14+
15+
#### Defaults
16+
17+
Basic options such as a default User or IdentityFile. Can be overridden by group or individual host entries.
18+
19+
#### Example
20+
21+
Example config demonstrating the use of the global and default options:
22+
23+
```yaml
24+
25+
---
26+
global:
27+
UseRoaming: "no"
28+
29+
default:
30+
User: ben
31+
IdentityFile: ~/.ssh/id_rsa
32+
33+
web_servers:
34+
Port: 2201
35+
IdentityFile: ~/.ssh/digital_ocean
36+
Hosts:
37+
projects-do-1:
38+
HostName: projects-do-1.example.com
39+
projects-do-2:
40+
HostName: projects-do-2.example.com
41+
projects-aws:
42+
HostName: projects-aws.example.com
43+
IdentityFile: ~/.ssh/aws
44+
45+
raspberry_pis:
46+
User: pi
47+
Hosts:
48+
pi1:
49+
HostName: 192.168.0.107
50+
pi2:
51+
HostName: 192.168.0.108
52+
53+
local:
54+
Hosts:
55+
router:
56+
HostName: 192.168.0.1
57+
User: root
58+
kodi:
59+
HostName: 192.168.0.200
60+
61+
work:
62+
User: bcromwell
63+
Hosts:
64+
workpc:
65+
HostName: 10.0.0.80
66+
gitlab:
67+
HostName: 10.0.0.30
68+
jenkins:
69+
HostName: 10.0.0.20
70+
71+
```

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22

33
setup(name='sshush',
4-
version='0.1',
4+
version='1.0.0',
55
description='SSH Config management tool',
66
url='http://github.com/bencromwell/sshush',
77
author='Ben Cromwell',

sshush/command_line.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import argparse
22
from os.path import expanduser
3-
from sshush.parser import read_file, process_yaml
3+
from sshush.sshush import read_file, process_yaml
44

55

66
def main():
7-
default_path = '{home}/.ssh/test-config'.format(home=expanduser('~'))
7+
default_path = '{home}/.ssh/config'.format(home=expanduser('~'))
8+
default_yaml_path = '{home}/.ssh/config.yml'.format(home=expanduser('~'))
89

910
arg_parser = argparse.ArgumentParser()
1011

11-
arg_parser.add_argument('yaml_file', help='Source YAML')
12+
arg_parser.add_argument(
13+
'--source', '-s',
14+
help='Path to source YAML file if it differs from {}'.format(default_yaml_path),
15+
default=default_yaml_path
16+
)
1217

1318
arg_parser.add_argument(
1419
'--path', '-p',
@@ -20,10 +25,10 @@ def main():
2025

2126
print('sshush running with path "{path}" and source YAML "{yaml}"'.format(
2227
path=args.path,
23-
yaml=args.yaml_file
28+
yaml=args.source
2429
))
2530

26-
yaml_obj = read_file(args.yaml_file)
31+
yaml_obj = read_file(args.source)
2732
config_file_contents = process_yaml(yaml_obj)
2833

2934
try:

sshush/parser.py renamed to sshush/sshush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def process_yaml(ssh_config_yaml):
2323
settings = {**defaults, **item}
2424

2525
for reference, host_details in hosts.items():
26-
output.append(reference)
26+
output.append('Host {}'.format(reference))
2727
host_settings = {**settings, **host_details}
2828

2929
for k, v in host_settings.items():

0 commit comments

Comments
 (0)