Skip to content

Commit 2440f28

Browse files
cguentherTUChemnitzhach-que
authored andcommitted
create missing ed25519 ssh host key on startupt (RedpointArchive#59)
* handle dynamically new sshd key types After some updates /usr/sbin/sshd-gen-keys-start produces more keys than before. It checks for existing ones and produces only the missing ones. This is necessary to support newer sshd protocolls. 45-phabricator-ssh script is now updated to dynamically generate missing key types and copy the new ones to PHABRICATOR_HOST_KEYS_PATH. Additionally the loaded keys from PHABRICATOR_HOST_KEYS_PATH are ensured to have correct file rights. In the current situation additional support for ed25519 key type is added. * fix ssh host key copy statement fix: cp: cannot stat '/etc/ssh/ssh_host__key': No such file or directory cp: cannot stat '/etc/ssh/ssh_host__key.pub': No such file or directory
1 parent 8e753c8 commit 2440f28

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

45-phabricator-ssh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ fi
1414
if [ ! -f /baked ]; then
1515
if [ -d $PHABRICATOR_HOST_KEYS_PATH ]; then
1616
cp -v $PHABRICATOR_HOST_KEYS_PATH/* /etc/ssh/
17-
else
17+
#ensure correct file modes of private keys
18+
chmod 600 /etc/ssh/ssh_host_{dsa_,ecdsa_,ed25519_,,rsa_}key
19+
fi
20+
#generate missing keys --> sshd needs sometimes more keys for newer protocolls
1821
/usr/sbin/sshd-gen-keys-start
1922
mkdir -pv $PHABRICATOR_HOST_KEYS_PATH
20-
cp -v /etc/ssh/ssh_host_key $PHABRICATOR_HOST_KEYS_PATH/
21-
cp -v /etc/ssh/ssh_host_key.pub $PHABRICATOR_HOST_KEYS_PATH/
22-
cp -v /etc/ssh/ssh_host_dsa_key $PHABRICATOR_HOST_KEYS_PATH/
23-
cp -v /etc/ssh/ssh_host_dsa_key.pub $PHABRICATOR_HOST_KEYS_PATH/
24-
cp -v /etc/ssh/ssh_host_rsa_key $PHABRICATOR_HOST_KEYS_PATH/
25-
cp -v /etc/ssh/ssh_host_rsa_key.pub $PHABRICATOR_HOST_KEYS_PATH/
26-
cp -v /etc/ssh/ssh_host_ecdsa_key $PHABRICATOR_HOST_KEYS_PATH/
27-
cp -v /etc/ssh/ssh_host_ecdsa_key.pub $PHABRICATOR_HOST_KEYS_PATH/
28-
fi
23+
#copy only when the file does not exist
24+
cp -vn /etc/ssh/ssh_host_{dsa_,ecdsa_,ed25519_,,rsa_}key{,.pub} $PHABRICATOR_HOST_KEYS_PATH/
2925
fi
3026

3127
if [ ! -f /is-baking ]; then

0 commit comments

Comments
 (0)