-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·31 lines (24 loc) · 1017 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# post-apply script that properly manages ssh authentication keys
# Install in /var/radmind/postapply
SSHKEYGEN=/usr/bin/ssh-keygen
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
$SSHKEYGEN -q -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" \
-C "" < /dev/null > /dev/null 2> /dev/null
echo "Created /etc/ssh_host_rsa_key"
fi
if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
$SSHKEYGEN -q -t dsa -f /etc/ssh/ssh_host_dsa_key -N "" \
-C "" < /dev/null > /dev/null 2> /dev/null
echo "Created /etc/ssh_host_dsa_key"
fi
# Install SSH keys
mkdir -p ~/.ssh
echo $JENKINS_PUBLIC_KEY | sed 's/\\\\n/\n/g' > ~/.ssh/authorized_keys
echo $GITLAB_SSH_PRIVATE_KEY | sed 's/\\\\n/\n/g' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
$SSHKEYGEN -yf ~/.ssh/id_rsa -q -P "" > ~/.ssh/id_rsa.pub || true
echo -e "Host u-test-factory.org\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config
echo -e "Host gitlab.u-test-factory.org\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# Run sshd
/usr/sbin/sshd -D