-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautossh-run
executable file
·35 lines (28 loc) · 1.03 KB
/
autossh-run
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
32
33
34
35
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo -e "\nNo parameters have been passed.\n"
exit 1
fi
if [ ! -r /root/.ssh/id_rsa ]; then
echo -e "\nWarning: There is no RSA key present in the image at "
echo -e "the SSH default location '/root/.ssh/id_rsa'.\n"
echo -e "Add or bind mount one or specify another in the config file.\n"
echo -e "These are the available RSA keys at /root/.ssh :"
ls -Al /root/.ssh/
echo
fi
AUTOSSH_CONF_DIR="/etc/autossh.conf.d/"
AUTOSSH_CONF_FILE="/etc/ssh/ssh_config"
if [ ! -r ${AUTOSSH_CONF_FILE} ]; then
echo -e "\nAutoSSH configuration file '${AUTOSSH_CONF_FILE}' does not exists."
echo -e "Available AutoSSH config files are:\n"
ls -Al ${AUTOSSH_DIR}
exit 1
fi
# Build ssh_config by including AUTOSSH_CONF_DIR defined hosts.
echo "Building ${AUTOSSH_CONF_FILE} from files in ${AUTOSSH_CONF_DIR}..."
cat ${AUTOSSH_CONF_DIR}/* | tee -a ${AUTOSSH_CONF_FILE}
echo -e "\n${AUTOSSH_CONF_FILE} built from the following files:"
ls -Al ${AUTOSSH_CONF_DIR}
echo
exec autossh -vNF ${AUTOSSH_CONF_FILE} $@