2016-11-28 18:43:18 +05:30
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ ! -d /data/ssh ]; then
|
|
|
|
mkdir -p /data/ssh
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f /data/ssh/ssh_host_ed25519_key ]; then
|
|
|
|
echo "Generating /data/ssh/ssh_host_ed25519_key..."
|
2019-04-04 10:39:38 +05:30
|
|
|
ssh-keygen -t ed25519 -f /data/ssh/ssh_host_ed25519_key -N "" > /dev/null
|
2016-11-28 18:43:18 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f /data/ssh/ssh_host_rsa_key ]; then
|
|
|
|
echo "Generating /data/ssh/ssh_host_rsa_key..."
|
|
|
|
ssh-keygen -t rsa -b 2048 -f /data/ssh/ssh_host_rsa_key -N "" > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f /data/ssh/ssh_host_dsa_key ]; then
|
|
|
|
echo "Generating /data/ssh/ssh_host_dsa_key..."
|
|
|
|
ssh-keygen -t dsa -f /data/ssh/ssh_host_dsa_key -N "" > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then
|
|
|
|
echo "Generating /data/ssh/ssh_host_ecdsa_key..."
|
|
|
|
ssh-keygen -t ecdsa -b 256 -f /data/ssh/ssh_host_ecdsa_key -N "" > /dev/null
|
|
|
|
fi
|
|
|
|
|
2019-07-07 07:27:53 +05:30
|
|
|
if [ -d /etc/ssh ]; then
|
|
|
|
SSH_PORT=${SSH_PORT:-"22"} \
|
2019-10-12 21:15:00 +05:30
|
|
|
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
|
2019-07-07 07:27:53 +05:30
|
|
|
envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config
|
|
|
|
|
|
|
|
chmod 0644 /etc/ssh/sshd_config
|
|
|
|
fi
|
|
|
|
|
2016-11-28 18:43:18 +05:30
|
|
|
chown root:root /data/ssh/*
|
|
|
|
chmod 0700 /data/ssh
|
|
|
|
chmod 0600 /data/ssh/*
|