Spaces:
Paused
Paused
BinaryONe commited on
Commit ·
e0b0924
1
Parent(s): d8b433e
Changes
Browse files
start.sh
CHANGED
|
@@ -48,8 +48,8 @@ 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 |
-
|
| 52 |
-
|
| 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; }
|
|
@@ -60,7 +60,7 @@ 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 |
-
|
| 64 |
chmod 600 /home/admin/.ssh/authorized_keys || { echo "Failed to set authorized_keys permissions"; exit 1; }
|
| 65 |
fi
|
| 66 |
}
|
|
@@ -98,7 +98,7 @@ change_account() {
|
|
| 98 |
|
| 99 |
if id -u "$username" >/dev/null 2>&1; then
|
| 100 |
echo "* Switching to user: $username *"
|
| 101 |
-
echo "$password" |
|
| 102 |
echo "* Now running as: $(whoami) *"
|
| 103 |
EOF
|
| 104 |
else
|
|
|
|
| 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; }
|
|
|
|
| 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 |
}
|
|
|
|
| 98 |
|
| 99 |
if id -u "$username" >/dev/null 2>&1; then
|
| 100 |
echo "* Switching to user: $username *"
|
| 101 |
+
echo "$password" | su -l "$username" -i <<'EOF'
|
| 102 |
echo "* Now running as: $(whoami) *"
|
| 103 |
EOF
|
| 104 |
else
|