aigems commited on
Commit
21dc2d1
·
1 Parent(s): 71849a1
Files changed (3) hide show
  1. Dockerfile +3 -1
  2. app.js +3 -2
  3. start.sh +9 -0
Dockerfile CHANGED
@@ -35,12 +35,14 @@ RUN npm install
35
  # 复制其余的源代码和公共文件
36
  COPY . .
37
 
 
 
38
  # 检查 UID 1000 是否存在,如果存在则删除,然后创建新用户
39
  RUN if id 1000 >/dev/null 2>&1; then \
40
  userdel -f $(id -nu 1000); \
41
  fi \
42
  && useradd -u 1000 -m -s /bin/bash user \
43
- && echo 'user:password' | chpasswd
44
 
45
  # 设置 Dropbear
46
  RUN mkdir -p /etc/dropbear \
 
35
  # 复制其余的源代码和公共文件
36
  COPY . .
37
 
38
+ ENV SSH_PASSWORD=password
39
+
40
  # 检查 UID 1000 是否存在,如果存在则删除,然后创建新用户
41
  RUN if id 1000 >/dev/null 2>&1; then \
42
  userdel -f $(id -nu 1000); \
43
  fi \
44
  && useradd -u 1000 -m -s /bin/bash user \
45
+ && echo "user:${SSH_PASSWORD}" | chpasswd
46
 
47
  # 设置 Dropbear
48
  RUN mkdir -p /etc/dropbear \
app.js CHANGED
@@ -26,9 +26,10 @@ app.post('/ssh', async (req, res) => {
26
  host: 'localhost',
27
  port: 2202,
28
  username: 'user',
29
- password: 'password',
30
  readyTimeout: 5000,
31
- debug: console.log
 
32
  });
33
  });
34
 
 
26
  host: 'localhost',
27
  port: 2202,
28
  username: 'user',
29
+ password: process.env.SSH_PASSWORD || 'password',
30
  readyTimeout: 5000,
31
+ debug: console.log,
32
+ tryKeyboard: true
33
  });
34
  });
35
 
start.sh CHANGED
@@ -37,6 +37,15 @@ done
37
 
38
  echo "Dropbear version: $(dropbear -V 2>&1)"
39
 
 
 
 
 
 
 
 
 
 
40
  # 显示 Dropbear 进程信息
41
  echo "Dropbear process:"
42
  ps aux | grep dropbear | grep -v grep
 
37
 
38
  echo "Dropbear version: $(dropbear -V 2>&1)"
39
 
40
+ # 测试 SSH 连接
41
+ echo "Testing SSH connection..."
42
+ if ssh -p 2202 -o StrictHostKeyChecking=no user@localhost 'echo "SSH connection successful"'; then
43
+ echo "SSH connection test passed"
44
+ else
45
+ echo "SSH connection test failed"
46
+ exit 1
47
+ fi
48
+
49
  # 显示 Dropbear 进程信息
50
  echo "Dropbear process:"
51
  ps aux | grep dropbear | grep -v grep