cpp-dev-env-docker/startup.sh
2024-10-12 16:55:37 +08:00

16 lines
395 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 检查 /etc/ssh 目录下是否已有主机密钥
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
echo "No SSH host key found, generating keys..."
ssh-keygen -A # 生成所有类型的主机密钥
else
echo "SSH host key already exists, skipping key generation."
fi
# 启动 SSH 守护进程
/usr/sbin/sshd
# 保持容器运行(进入交互式 bash
exec /bin/bash