Skip to content

Commit f91025d

Browse files
Merge pull request #523 from frappe/mergify/bp/master/pr-522
fix(build): Ensure public keys are used correctly (backport #522)
2 parents 755059e + bf322f1 commit f91025d

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

agent/build_configs/sshd_config

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
ListenAddress 0.0.0.0
2+
PidFile /home/frappe/frappe-bench/config/ssh/sshd.pid
3+
Port 2200
4+
5+
6+
# Logging
7+
LogLevel VERBOSE
8+
SyslogFacility AUTH
9+
10+
11+
# Authentication
12+
PermitRootLogin no
13+
StrictModes yes
14+
15+
AuthenticationMethods publickey
16+
PubkeyAuthentication yes
17+
18+
19+
# Disable Other Authentication Methods
20+
ChallengeResponseAuthentication no
21+
GSSAPIAuthentication no
22+
HostbasedAuthentication no
23+
KbdInteractiveAuthentication no
24+
KerberosAuthentication no
25+
PasswordAuthentication no
26+
PermitEmptyPasswords no
27+
UsePAM no
28+
29+
30+
# Certificates
31+
AuthorizedKeysFile none
32+
TrustedUserCAKeys /home/frappe/frappe-bench/config/ssh/ca.pub
33+
AuthorizedPrincipalsFile /home/frappe/frappe-bench/config/ssh/principals
34+
35+
HostKey /home/frappe/frappe-bench/config/ssh/ssh_host_rsa_key
36+
HostCertificate /home/frappe/frappe-bench/config/ssh/ssh_host_rsa_key-cert.pub
37+
38+
39+
# Capability Limits
40+
AllowAgentForwarding no
41+
AllowStreamLocalForwarding no
42+
AllowTcpForwarding no
43+
44+
GatewayPorts no
45+
46+
PermitListen none
47+
PermitOpen none
48+
49+
PermitTunnel no
50+
PermitUserEnvironment no
51+
PermitUserRC no
52+
53+
PrintMotd no
54+
55+
X11Forwarding no
56+
X11UseLocalhost yes
57+
58+
59+
# Interactive Terminal
60+
PermitTTY yes
61+
62+
63+
# Rate Limit
64+
LoginGraceTime 20
65+
MaxAuthTries 3
66+
MaxSessions 10
67+
MaxStartups 10:30:100

agent/builder.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,13 @@ def _write_ssh_key_files(self, config_dir: str):
175175
ssh_dir = os.path.join(config_dir, "ssh")
176176
os.makedirs(ssh_dir, exist_ok=True)
177177

178+
shutil.copy(os.path.join(self.build_config_path, "config", "ssh", "sshd_config"), ssh_dir)
179+
178180
host = self.ssh_keys["host"]
179181
with open(os.path.join(ssh_dir, "ssh_host_rsa_key"), "w") as f:
180182
f.write(host["private_key"])
183+
with open(os.path.join(ssh_dir, "ssh_host_rsa_key.pub"), "w") as f:
184+
f.write(host["public_key"])
181185
with open(os.path.join(ssh_dir, "ssh_host_rsa_key-cert.pub"), "w") as f:
182186
f.write(host["certificate"])
183187
with open(os.path.join(ssh_dir, "ca.pub"), "w") as f:

0 commit comments

Comments
 (0)