privateone commited on
Commit
31103ff
·
verified ·
1 Parent(s): 75abc3a

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +16 -2
start.sh CHANGED
@@ -7,14 +7,28 @@ print_host_details() {
7
  echo "* The host File 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 "* Changing User to Admin :$(echo "toor" || su - admin)"
11
  echo "* Current User WHO AM I $(whoami)"
12
  echo "* Status of Admin: $(id admin 2>/dev/null || echo 'Admin user not found')"
13
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # Function to start SSH service if not running
15
  start_ssh_service() {
16
  if ! pgrep -x "sshd" >/dev/null; then
17
- echo "* Starting SSH server on port 2222 *"
18
  /usr/sbin/sshd -p 2222 || { echo "Failed to start SSH server"; exit 1; }
19
  #/usr/sbin/sshd -D -e -ddd|| { echo "Failed to start SSH server"; exit 1; }
20
  else
 
7
  echo "* The host File 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 "* Changing User to Admin :$(echo "toor" || su - admin)"
11
  echo "* Current User WHO AM I $(whoami)"
12
  echo "* Status of Admin: $(id admin 2>/dev/null || echo 'Admin user not found')"
13
  }
14
+ # Function to generate SSH host keys if missing
15
+ generate_ssh_keys() {
16
+ if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
17
+ echo "* Generating SSH host keys *"
18
+ yes y | ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" || { echo "Failed to generate RSA key"; exit 1; }
19
+ yes y | ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" || { echo "Failed to generate ECDSA key"; exit 1; }
20
+ yes y | ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" || { echo "Failed to generate ED25519 key"; exit 1; }
21
+ ssh-keyscan -p 2222 127.0.0.1 >> /home/admin/.ssh/known_hosts
22
+ cp /home/admin/.ssh/known_hosts /home/admin/.ssh/ssh_known_host
23
+ #ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ""
24
+ #ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N ""
25
+ #ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
26
+ fi
27
+ }
28
  # Function to start SSH service if not running
29
  start_ssh_service() {
30
  if ! pgrep -x "sshd" >/dev/null; then
31
+ echo "* Starting SSH server at port 2222 *"
32
  /usr/sbin/sshd -p 2222 || { echo "Failed to start SSH server"; exit 1; }
33
  #/usr/sbin/sshd -D -e -ddd|| { echo "Failed to start SSH server"; exit 1; }
34
  else