Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2dffc735a4 | |||
| 25bd8373ae | |||
| 0469699073 | |||
| 4282982c22 | |||
| 517c5fc27d | |||
| 18a3898865 | |||
| b761687fe7 | |||
| 2fa5293562 | |||
| d42fccd836 | |||
| 4df9913fce | |||
| d775ea5fe4 | |||
| bcf3839773 | |||
| 017a25c3e5 | |||
| aba51e76b8 | |||
| 758cedfc21 | |||
| af711687cd | |||
| c7500beee9 | |||
| c531b82e24 | |||
| 9d6db4bb40 | |||
| e28d5291c3 | |||
|
|
b476a3e2cf | ||
|
|
c8e6646009 | ||
|
|
0be1013d72 | ||
| 3dd0003bcc | |||
|
|
f88c3dba56 | ||
| 9cf9efbdb7 | |||
|
|
cc10132cd3 |
17
nasp-jumpserver/Dockerfile
Normal file
17
nasp-jumpserver/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM docker.io/alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache openssh git sudo tmux vim bash zsh curl wget coreutils util-linux tzdata shadow iputils \
|
||||||
|
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
COPY sshd_config /etc/ssh/sshd_config
|
||||||
|
COPY ssh_config /etc/ssh/ssh_config
|
||||||
|
COPY startup.sh /etc/startup.sh
|
||||||
|
|
||||||
|
RUN cd /opt && git clone https://git.nasp.fit/NASP/registry \
|
||||||
|
&& ./registry/scripts/jumpserver_deploy.sh \
|
||||||
|
&& curl dotfiles.cn | bash -s - -l -u root \
|
||||||
|
&& sed -i 's?root:x:0:0:root:/root:/bin/sh?root:x:0:0:root:/root:/bin/zsh?' /etc/passwd \
|
||||||
|
&& sed -i 's?ssh:x:1000:1000:jumpserver user ssh:/home/ssh:/bin/sh?ssh:x:1000:1000:jumpserver user ssh:/home/ssh:/bin/bash?' /etc/passwd
|
||||||
|
|
||||||
|
EXPOSE 22
|
||||||
|
ENTRYPOINT ["/etc/startup.sh"]
|
||||||
28
nasp-jumpserver/README.md
Normal file
28
nasp-jumpserver/README.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
## NASP Jump Server Docker Image
|
||||||
|
|
||||||
|
Tag:
|
||||||
|
|
||||||
|
```
|
||||||
|
git.nasp.fit/nasp/nasp-jumpserver
|
||||||
|
```
|
||||||
|
|
||||||
|
To run:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -itd --restart=always -p 36022:22 git.nasp.fit/nasp/nasp-jumpserver:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Or with docker-compose:
|
||||||
|
|
||||||
|
```
|
||||||
|
jumpserver:
|
||||||
|
ports:
|
||||||
|
- 36022:22
|
||||||
|
container_name: jumpserver
|
||||||
|
image: git.nasp.fit/nasp/nasp-jumpserver
|
||||||
|
tty: true
|
||||||
|
dns: 10.255.0.1
|
||||||
|
dns_search: ""
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: bridge
|
||||||
|
```
|
||||||
2
nasp-jumpserver/ssh_config
Normal file
2
nasp-jumpserver/ssh_config
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Host *
|
||||||
|
ForwardAgent yes
|
||||||
16
nasp-jumpserver/sshd_config
Normal file
16
nasp-jumpserver/sshd_config
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Port 22
|
||||||
|
|
||||||
|
# Authentication:
|
||||||
|
LoginGraceTime 30s
|
||||||
|
PermitRootLogin prohibit-password
|
||||||
|
StrictModes yes
|
||||||
|
MaxAuthTries 6
|
||||||
|
MaxSessions 10
|
||||||
|
PubkeyAuthentication yes
|
||||||
|
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
|
||||||
|
PasswordAuthentication no
|
||||||
|
AllowAgentForwarding yes
|
||||||
|
PubkeyAcceptedAlgorithms=+ssh-rsa
|
||||||
|
|
||||||
|
# override default of no subsystems
|
||||||
|
Subsystem sftp internal-sftp
|
||||||
7
nasp-jumpserver/startup.sh
Executable file
7
nasp-jumpserver/startup.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
test -f /etc/ssh/ssh_host_rsa_key || ssh-keygen -A
|
||||||
|
crond
|
||||||
|
/usr/sbin/sshd
|
||||||
|
bash
|
||||||
18
nasp-ubuntu-neo/Dockerfile
Normal file
18
nasp-ubuntu-neo/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
FROM docker.io/nvidia/cuda:12.2.2-devel-ubuntu22.04
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||||
|
&& sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn/ubuntu@g" /etc/apt/sources.list \
|
||||||
|
&& apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -yq \
|
||||||
|
-o Acquire::BrokenProxy="true" -o Acquire::http::No-Cache="true" -o Acquire::http::Pipeline-Depth="0" \
|
||||||
|
build-essential cmake openssh-server git-all sudo ssh sshpass pciutils \
|
||||||
|
python3 python3-dev python3-pip curl ca-certificates vim zsh tmux bash \
|
||||||
|
inetutils-ping less wget dialog net-tools dnsutils netcat traceroute \
|
||||||
|
cron htop zip openssl \
|
||||||
|
&& curl -fsSL https://code-server.dev/install.sh | sh \
|
||||||
|
&& rm -rf /var/lib/apt/list/*
|
||||||
|
|
||||||
|
# startup
|
||||||
|
COPY startup.sh /etc/startup.sh
|
||||||
|
COPY code.sh /usr/bin/code.sh
|
||||||
|
ENTRYPOINT ["/etc/startup.sh"]
|
||||||
23
nasp-ubuntu-neo/code.sh
Executable file
23
nasp-ubuntu-neo/code.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
FMT_RED=$(printf '\033[31m')
|
||||||
|
FMT_GREEN=$(printf '\033[32m')
|
||||||
|
FMT_YELLOW=$(printf '\033[33m')
|
||||||
|
FMT_BLUE=$(printf '\033[34m')
|
||||||
|
FMT_BOLD=$(printf '\033[1m')
|
||||||
|
FMT_RESET=$(printf '\033[0m')
|
||||||
|
|
||||||
|
if [[ -d /home2/run && -x $(command -v code-server) ]]; then
|
||||||
|
if ps -ef | grep -v grep | grep -q code-server; then
|
||||||
|
sockpath=$(basename $(grep "socket:" ~/.config/code-server/config.yaml | awk -F' ' '{print $2}') .sock)
|
||||||
|
password=$(grep "password:" ~/.config/code-server/config.yaml | awk -F' ' '{print $2}')
|
||||||
|
echo "${FMT_GREEN}code-server is running${FMT_RESET}"
|
||||||
|
echo "visit: https://proxy.nasp.fit/$(hostname)/$sockpath/"
|
||||||
|
echo "password: $password"
|
||||||
|
else
|
||||||
|
echo "${FMT_RED}code-server is not running${FMT_RESET}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "${FMT_RED}code-server is not set up${FMT_RESET}"
|
||||||
|
fi
|
||||||
28
nasp-ubuntu-neo/startup.sh
Executable file
28
nasp-ubuntu-neo/startup.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo $@
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/etc/init.d/ssh start || echo "Failed to start sshd. Maybe the port is already in use, and please check your sshd_config. This is not an error if it's the first time you run this container."
|
||||||
|
if [[ ! -e /root/.config/code-server/config.yaml ]]; then
|
||||||
|
mkdir -p /root/.config/code-server
|
||||||
|
sockname=$(openssl rand -hex 12)
|
||||||
|
test "${#sockname}" = "24" || error "invalid sock name: ${sockname}"
|
||||||
|
password=$(openssl rand -base64 15)
|
||||||
|
test -n "$password" || error "invalid password: ${password}"
|
||||||
|
cat << EOF > /root/.config/code-server/config.yaml
|
||||||
|
socket: /home2/run/$sockname.sock
|
||||||
|
socket-mode: 777
|
||||||
|
auth: password
|
||||||
|
password: $password
|
||||||
|
cert: false
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [[ -d /home2/run && -x $(command -v code-server) ]]; then
|
||||||
|
code-server
|
||||||
|
else
|
||||||
|
bash
|
||||||
|
fi
|
||||||
25
nasp-ubuntu/Dockerfile
Normal file
25
nasp-ubuntu/Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
FROM docker.io/nvidia/cuda:11.3.1-devel-ubuntu20.04
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||||
|
&& sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn/ubuntu@g" /etc/apt/sources.list \
|
||||||
|
&& apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -yq \
|
||||||
|
-o Acquire::BrokenProxy="true" -o Acquire::http::No-Cache="true" -o Acquire::http::Pipeline-Depth="0" \
|
||||||
|
build-essential cmake openssh-server git-all sudo ssh sshpass pciutils \
|
||||||
|
python3 python3-dev python3-pip curl ca-certificates vim zsh tmux bash \
|
||||||
|
inetutils-ping less wget dialog net-tools dnsutils netcat traceroute \
|
||||||
|
cron htop zip openssl \
|
||||||
|
&& curl -fsSL https://code-server.dev/install.sh | sh \
|
||||||
|
&& rm -rf /var/lib/apt/list/*
|
||||||
|
|
||||||
|
# mlnx ofed
|
||||||
|
RUN cd /tmp && wget http://192.168.16.118/drivers/MLNX_OFED_LINUX-5.8-3.0.7.0-ubuntu20.04-x86_64.tgz \
|
||||||
|
&& tar -xf MLNX_OFED_LINUX-5.8-3.0.7.0-ubuntu20.04-x86_64.tgz \
|
||||||
|
&& cd MLNX_OFED_LINUX-5.8-3.0.7.0-ubuntu20.04-x86_64 \
|
||||||
|
&& ./mlnxofedinstall --skip-unsupported-devices-check -q \
|
||||||
|
&& rm -rf /tmp/MLNX_OFED_LINUX-5.8-*
|
||||||
|
|
||||||
|
# startup
|
||||||
|
COPY startup.sh /etc/startup.sh
|
||||||
|
COPY code.sh /usr/bin/code.sh
|
||||||
|
ENTRYPOINT ["/etc/startup.sh"]
|
||||||
23
nasp-ubuntu/code.sh
Executable file
23
nasp-ubuntu/code.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
FMT_RED=$(printf '\033[31m')
|
||||||
|
FMT_GREEN=$(printf '\033[32m')
|
||||||
|
FMT_YELLOW=$(printf '\033[33m')
|
||||||
|
FMT_BLUE=$(printf '\033[34m')
|
||||||
|
FMT_BOLD=$(printf '\033[1m')
|
||||||
|
FMT_RESET=$(printf '\033[0m')
|
||||||
|
|
||||||
|
if [[ -d /home2/run && -x $(command -v code-server) ]]; then
|
||||||
|
if ps -ef | grep -v grep | grep -q code-server; then
|
||||||
|
sockpath=$(basename $(grep "socket:" ~/.config/code-server/config.yaml | awk -F' ' '{print $2}') .sock)
|
||||||
|
password=$(grep "password:" ~/.config/code-server/config.yaml | awk -F' ' '{print $2}')
|
||||||
|
echo "${FMT_GREEN}code-server is running${FMT_RESET}"
|
||||||
|
echo "visit: https://proxy.nasp.fit/$(hostname)/$sockpath/"
|
||||||
|
echo "password: $password"
|
||||||
|
else
|
||||||
|
echo "${FMT_RED}code-server is not running${FMT_RESET}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "${FMT_RED}code-server is not set up${FMT_RESET}"
|
||||||
|
fi
|
||||||
28
nasp-ubuntu/startup.sh
Executable file
28
nasp-ubuntu/startup.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo $@
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/etc/init.d/ssh start || echo "Failed to start sshd. Maybe the port is already in use, and please check your sshd_config. This is not an error if it's the first time you run this container."
|
||||||
|
if [[ ! -e /root/.config/code-server/config.yaml ]]; then
|
||||||
|
mkdir -p /root/.config/code-server
|
||||||
|
sockname=$(openssl rand -hex 12)
|
||||||
|
test "${#sockname}" = "24" || error "invalid sock name: ${sockname}"
|
||||||
|
password=$(openssl rand -base64 15)
|
||||||
|
test -n "$password" || error "invalid password: ${password}"
|
||||||
|
cat << EOF > /root/.config/code-server/config.yaml
|
||||||
|
socket: /home2/run/$sockname.sock
|
||||||
|
socket-mode: 777
|
||||||
|
auth: password
|
||||||
|
password: $password
|
||||||
|
cert: false
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [[ -d /home2/run && -x $(command -v code-server) ]]; then
|
||||||
|
code-server
|
||||||
|
else
|
||||||
|
bash
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user