privateone commited on
Commit
7381827
·
verified ·
1 Parent(s): 21e483f

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +5 -3
start.sh CHANGED
@@ -5,7 +5,8 @@ print_host_details() {
5
  #echo "0.0.0.0 abc" | sudo tee -a /etc/hosts
6
  echo "* The hostname of this container is: $(cat /etc/hostname)"
7
  echo "* The host of this container is: $(cat /etc/hosts)"
8
- echo "* ID of the user running the script: $(id -u) * Group: $(id -g)"
 
9
  echo "* Status of Admin: $(id admin 2>/dev/null || echo 'Admin user not found')"
10
  }
11
 
@@ -59,7 +60,7 @@ generate_admin_ssh_keys() {
59
  #ssh-keygen -t rsa -b 2048 -f /home/admin/.ssh/id_rsa -q -N ""
60
  #yes y | ssh-keygen -t rsa -b 2048 -f /home/admin/.ssh/id_rsa -N "" || { echo "Failed to generate admin SSH key"; exit 1; }
61
  yes y | ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa
62
- cat ~/.ssh/id_rsa.pub
63
  chmod 700 /home/admin/.ssh || { echo "Failed to set .ssh directory permissions"; exit 1; }
64
  chmod 600 /home/admin/.ssh/id_rsa || { echo "Failed to set private key permissions"; exit 1; }
65
  chmod 644 /home/admin/.ssh/id_rsa.pub || { echo "Failed to set public key permissions"; exit 1; }
@@ -69,7 +70,8 @@ generate_admin_ssh_keys() {
69
  # Function to add public key to authorized_keys for 'admin' user
70
  add_admin_authorized_keys() {
71
  echo "* Adding public key to authorized_keys for 'admin' user *"
72
- cat /home/admin/.ssh/id_rsa.pub >> /home/admin/.ssh/authorized_keys || { echo "Failed to add public key to authorized_keys"; exit 1; }
 
73
  chmod 600 /home/admin/.ssh/authorized_keys || { echo "Failed to set authorized_keys permissions"; exit 1; }
74
  }
75
 
 
5
  #echo "0.0.0.0 abc" | sudo tee -a /etc/hosts
6
  echo "* The hostname of this container is: $(cat /etc/hostname)"
7
  echo "* The host of this container is: $(cat /etc/hosts)"
8
+ echo "* The Sudoers of this container is: $(cat /etc/sudoers)"
9
+ echo "* ID of the user running the script:($whoami) *ID : $(id -u) * Group: $(id -g)"
10
  echo "* Status of Admin: $(id admin 2>/dev/null || echo 'Admin user not found')"
11
  }
12
 
 
60
  #ssh-keygen -t rsa -b 2048 -f /home/admin/.ssh/id_rsa -q -N ""
61
  #yes y | ssh-keygen -t rsa -b 2048 -f /home/admin/.ssh/id_rsa -N "" || { echo "Failed to generate admin SSH key"; exit 1; }
62
  yes y | ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa
63
+ chown -R admin:admin ~/.ssh
64
  chmod 700 /home/admin/.ssh || { echo "Failed to set .ssh directory permissions"; exit 1; }
65
  chmod 600 /home/admin/.ssh/id_rsa || { echo "Failed to set private key permissions"; exit 1; }
66
  chmod 644 /home/admin/.ssh/id_rsa.pub || { echo "Failed to set public key permissions"; exit 1; }
 
70
  # Function to add public key to authorized_keys for 'admin' user
71
  add_admin_authorized_keys() {
72
  echo "* Adding public key to authorized_keys for 'admin' user *"
73
+ cat ~/.ssh/id_rsa.pub
74
+ cp ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys || { echo "Failed to add public key to authorized_keys"; exit 1; }
75
  chmod 600 /home/admin/.ssh/authorized_keys || { echo "Failed to set authorized_keys permissions"; exit 1; }
76
  }
77