forked from open-quantum-safe/oqs-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverstart.sh
executable file
·47 lines (38 loc) · 1.68 KB
/
serverstart.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
[[ $DEBUGLVL -gt 1 ]] && set -ex
OPTIONS=${OPTIONS:=""}
SIG=${SIG_ALG:="ecdsa-nistp384-dilithium3"}
KEM=${KEM_ALG:="[email protected]"}
# Optionally set port
# if left empty, the options defined in sshd_config will be used
if [ "x$SERVER_PORT" != "x" ]; then
OPTIONS="${OPTIONS} -p ${SERVER_PORT}"
fi
# Optionally set KEM to one defined in https://github.com/open-quantum-safe/openssh#key-exchange
# if left empty, the options defined in sshd_config will be used
if [ "x$KEM" != "x" ]; then
OPTIONS="${OPTIONS} -o KexAlgorithms=${KEM}"
fi
# Optionally set SIG to one defined in https://github.com/open-quantum-safe/openssh#digital-signature
# if left empty, the options defined in sshd_config will be used
if [ "x$SIG" != "x" ]; then
OPTIONS="${OPTIONS} -o HostKeyAlgorithms=ssh-${SIG} -o PubkeyAcceptedKeyTypes=ssh-${SIG}"
HOST_KEY_FILE="${OQS_INSTALL_DIR}/ssh_host_${SIG//-/_}_key"
OPTIONS="${OPTIONS} -h ${HOST_KEY_FILE}"
fi
# Generate host keys
# SSH_DIR="/home/${OQS_USER}/.ssh"
HOST_KEY_FILE="${SSH_DIR}/ssh_host_${SIG//-/_}_key"
echo "y" | ${OQS_INSTALL_DIR}/bin/ssh-keygen -t ssh-${SIG} -f ${OQS_INSTALL_DIR}/${HOST_KEY_FILE} -N "" -q
echo ""
# cat ${HOST_KEY_FILE}.pub >> ${SSH_DIR}/authorized_keys
[[ $DEBUGLVL -gt 0 ]] && echo "Debug1: New host key '${HOST_KEY_FILE}(.pub)' created!"
# OPTIONS="${OPTIONS} -i ${HOST_KEY_FILE}"
# Start the OQS SSH Daemon with the configuration as in ${OQS_INSTALL_DIR}/sshd_config
CMD="${OQS_INSTALL_DIR}/sbin/sshd ${OPTIONS}"
[[ $DEBUGLVL -gt 0 ]] && echo $CMD
eval $CMD
# Open a shell for local experimentation if not testing the connection
if [ "x${CONNECT_TEST}" == "x" ]; then
sh
fi