Mercurial > code > home > repos > infra
annotate ssh.py @ 238:a521d08d2b0d
upgrade syncthing
author | drewp@bigasterisk.com |
---|---|
date | Mon, 27 Nov 2023 22:15:10 -0800 |
parents | ff8879eed64e |
children | 4e424a144183 |
rev | line source |
---|---|
12 | 1 from pyinfra import host |
2 from pyinfra.facts.server import LinuxDistribution | |
3 from pyinfra.operations import files, systemd | |
4 | |
5 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] | |
6 | |
7 systemd.service( | |
8 service='ssh', | |
9 running=True, | |
10 enabled=True, | |
11 ) | |
12 | |
13 files.line(path='/etc/ssh/ssh_config', line="HashKnownHosts", replace="HashKnownHosts no") | |
14 | |
15 if is_pi: | |
16 auth_keys = '/home/pi/.ssh/authorized_keys' | |
17 files.file(path=auth_keys, user='pi', group='pi', mode=600) | |
18 for pubkey in [ | |
19 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNlR7hereUHqw/RHQau0F7+vQZKAxduM+SD4R76FhC+4Zi078Pv04ZLe9qdM/NBlB/grLGhG58vaGmnWPpJ3QJs= drewp@plus', | |
20 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOR+iV8Qm/rAfmq0epXYfnp5ZTfBl8eidFzw1GmyZ3fPUFAshWn839fQ5DPj9xDPtMy9kTtrB5bK1SnynFzDqzQ= drewp@bang', | |
21 ]: | |
22 files.line(path=auth_keys, line=pubkey, replace=pubkey) | |
98
3d4340fbb16c
finish moving these lines from system.py
drewp@bigasterisk.com
parents:
12
diff
changeset
|
23 |
3d4340fbb16c
finish moving these lines from system.py
drewp@bigasterisk.com
parents:
12
diff
changeset
|
24 if not is_pi: |
3d4340fbb16c
finish moving these lines from system.py
drewp@bigasterisk.com
parents:
12
diff
changeset
|
25 files.line(path='/etc/ssh/sshd_config', line="^UseDNS\b", replace="UseDNS no") |
237 | 26 # MAYBE plus needs this fix: adding ListenAddress 0.0.0.0 to /etc/ssh/sshd_config |
98
3d4340fbb16c
finish moving these lines from system.py
drewp@bigasterisk.com
parents:
12
diff
changeset
|
27 systemd.service(service='sshd', reloaded=True) |