#!/bin/bash echo "* Hi There I am Booting up : $(whoami)" mount -o remount / # Function to print the current hostname and user details #echo "0.0.0.0 abc" | sudo tee -a /etc/hosts echo "* The hostname of this container is: $(cat /etc/hostname). PWD $(pwd)" echo "* The host File of this container is: $(cat /etc/hosts)" echo "* The Sudoers of this container is: $(sudo cat /etc/sudoers)" echo "* ID of the user running the script: $(whoami) *ID : $(id -u) * Group: $(id -g)" echo "* Changing User to Admin :$(echo "password" || su - admin)" echo "* Current User WHO AM I $(whoami)" echo "* Status of Admin : $(id admin 2>/dev/null || echo 'Admin user not found')" # Function to generate SSH host keys if missing sudo rm -rf /etc/ssh/ssh_host_rsa_* sudo rm -rf /etc/ssh/ssh_host_ecdsa_* sudo rm -rf /etc/ssh/ssh_host_ed25519_* sudo rm -rf /etc/ssh/ssh_known_* echo "* Generating SSH host keys *" yes y | ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" || { echo "Failed to generate RSA key"; exit 1; } yes y | ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" || { echo "Failed to generate ECDSA key"; exit 1; } yes y | ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" || { echo "Failed to generate ED25519 key"; exit 1; } ssh-keyscan -p 2222 127.0.0.1 >> /etc/ssh/ssh_known_hosts cp /etc/ssh/ssh_known_hosts /etc/ssh/known_host #ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" #ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" #ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" #echo "* Public Key:" #cat /etc/ssh/ssh_host_rsa_key.pub #echo "* Private Key :" #cat /etc/ssh/ssh_host_rsa_key #echo "* Host Files :" #cat /etc/ssh/ssh_known_host # Function to start SSH service if not running #service ssh restart #service sshd restart echo "* Starting SSH server at port 2222 *" /usr/sbin/sshd -p 2222 || { echo "Failed to start SSH server"; exit 1; } #/usr/sbin/sshd -D -e -ddd|| { echo "Failed to start SSH server"; exit 1; } echo "* Status of SSH service: *" netstat -tuln /app/start.sh