mirror of
https://gitee.com/devstar/devcontainer-tweak.git
synced 2025-04-27 03:53:09 +00:00
Updated SSH DevContainer of MS Ubuntu 20.04
This commit is contained in:
commit
fe49bd173e
12
dev-ubuntu-20.04-ssh/Dockerfile
Normal file
12
dev-ubuntu-20.04-ssh/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM mcr.microsoft.com/devcontainers/base:dev-ubuntu-20.04
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
RUN apt-get update && apt-get install -y openssh-server && apt-get clean && chmod +x /entrypoint.sh
|
||||
|
||||
|
||||
# 当有命令传入时候执行命令,否则执行 tail -f /dev/null
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD []
|
||||
|
||||
# $ docker build -t base-ssh-devcontainer:ubuntu-20.04-20241014 .
|
17
dev-ubuntu-20.04-ssh/entrypoint.sh
Normal file
17
dev-ubuntu-20.04-ssh/entrypoint.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 1. 重新生成 SSH 密钥对
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
ssh-keygen -A
|
||||
|
||||
# 2. 启动 SSH 服务
|
||||
service ssh start
|
||||
|
||||
# 3. 默认命令检查
|
||||
if [ "$#" -eq 0 ]; then
|
||||
# 如果没有传入参数,则默认执行 tail -f /dev/null
|
||||
exec tail -f /dev/null
|
||||
else
|
||||
# 执行传入的命令
|
||||
exec "$@"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user