BinaryONe commited on
Commit
967b751
·
1 Parent(s): cf60697
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. start.sh +7 -7
Dockerfile CHANGED
@@ -38,7 +38,7 @@ RUN useradd -m -s /bin/bash admin && \
38
  COPY . /app
39
 
40
  # Create necessary directories and set permissions
41
- RUN mkdir -p /var/run/sshd /app /app/users/ssh /app/ssh && \
42
  chmod -R 777 /app
43
  # touch /etc/sudoers
44
 
 
38
  COPY . /app
39
 
40
  # Create necessary directories and set permissions
41
+ RUN mkdir -p /var/run/sshd /app /app/users/sshs /app/ssh && \
42
  chmod -R 777 /app
43
  # touch /etc/sudoers
44
 
start.sh CHANGED
@@ -48,11 +48,11 @@ fix_admin_permissions() {
48
  generate_admin_ssh_keys() {
49
  if [ ! -f /home/admin/.ssh/id_rsa ]; then
50
  echo "* Generating SSH keys for 'admin' user *"
51
- mkdir -p /home/admin/.ssh || { echo "Failed to create .ssh directory"; exit 1; }
52
- ssh-keygen -t rsa -b 2048 -f /home/admin/.ssh/id_rsa -q -N "" || { echo "Failed to generate admin SSH key"; exit 1; }
53
- chmod 700 /home/admin/.ssh || { echo "Failed to set .ssh directory permissions"; exit 1; }
54
- chmod 600 /home/admin/.ssh/id_rsa || { echo "Failed to set private key permissions"; exit 1; }
55
- chmod 644 /home/admin/.ssh/id_rsa.pub || { echo "Failed to set public key permissions"; exit 1; }
56
  fi
57
  }
58
 
@@ -60,8 +60,8 @@ generate_admin_ssh_keys() {
60
  add_admin_authorized_keys() {
61
  if [ ! -f /home/admin/.ssh/authorized_keys ]; then
62
  echo "* Adding public key to authorized_keys for 'admin' user *"
63
- bash -c "cat /home/admin/.ssh/id_rsa.pub >> /home/admin/.ssh/authorized_keys" || { echo "Failed to add public key to authorized_keys"; exit 1; }
64
- chmod 600 /home/admin/.ssh/authorized_keys || { echo "Failed to set authorized_keys permissions"; exit 1; }
65
  fi
66
  }
67
 
 
48
  generate_admin_ssh_keys() {
49
  if [ ! -f /home/admin/.ssh/id_rsa ]; then
50
  echo "* Generating SSH keys for 'admin' user *"
51
+ mkdir -p /app/users/sshs/admin //app/users/sshs/admin/.ssh || { echo "Failed to create .ssh directory"; exit 1; }
52
+ ssh-keygen -t rsa -b 2048 -f /app/users/sshs/admin/.ssh/id_rsa -q -N "" || { echo "Failed to generate admin SSH key"; exit 1; }
53
+ chmod 700 /app/users/sshs/admin/.ssh || { echo "Failed to set .ssh directory permissions"; exit 1; }
54
+ chmod 600 /app/users/sshs/admin/.ssh/id_rsa || { echo "Failed to set private key permissions"; exit 1; }
55
+ chmod 644 /app/users/sshs/admin/.ssh/id_rsa.pub || { echo "Failed to set public key permissions"; exit 1; }
56
  fi
57
  }
58
 
 
60
  add_admin_authorized_keys() {
61
  if [ ! -f /home/admin/.ssh/authorized_keys ]; then
62
  echo "* Adding public key to authorized_keys for 'admin' user *"
63
+ bash -c "cat /app/users/sshs/admin/.ssh/id_rsa.pub >> /app/users/sshs/admin/.ssh/authorized_keys" || { echo "Failed to add public key to authorized_keys"; exit 1; }
64
+ chmod 600 /app/users/sshs/admin/.ssh/authorized_keys || { echo "Failed to set authorized_keys permissions"; exit 1; }
65
  fi
66
  }
67