Spaces:
Paused
Paused
BinaryONe commited on
Commit ·
e38f7d2
1
Parent(s): c6ecbc2
Changes
Browse files
start.sh
CHANGED
|
@@ -41,7 +41,7 @@ create_admin_user() {
|
|
| 41 |
fix_admin_permissions() {
|
| 42 |
echo "* Fixing permissions for 'admin' user *"
|
| 43 |
chown -R admin:admin /home/admin || { echo "Failed to change ownership"; exit 1; }
|
| 44 |
-
chmod -R
|
| 45 |
}
|
| 46 |
|
| 47 |
# Function to generate SSH keys for 'admin' user if missing
|
|
@@ -50,9 +50,9 @@ generate_admin_ssh_keys() {
|
|
| 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
|
| 54 |
-
chmod
|
| 55 |
-
chmod
|
| 56 |
fi
|
| 57 |
}
|
| 58 |
|
|
@@ -61,7 +61,7 @@ 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 |
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
|
| 65 |
fi
|
| 66 |
}
|
| 67 |
|
|
@@ -127,15 +127,15 @@ fi
|
|
| 127 |
#eval $(ssh-agent -s) || { echo "Failed to start SSH agent"; exit 1; }
|
| 128 |
|
| 129 |
# Ensure SSHD config is correctly set up
|
| 130 |
-
echo "* Configuring SSHD *"
|
| 131 |
-
echo "UseKeychain yes" >> /home/admin/.ssh/config
|
| 132 |
-
echo "AddKeysToAgent yes" >> /home/admin/.ssh/config
|
| 133 |
|
| 134 |
# Restart SSH service
|
| 135 |
#service ssh restart || { echo "Failed to restart SSH service"; exit 1; }
|
| 136 |
|
| 137 |
|
| 138 |
-
add_ssh_key_to_agent
|
| 139 |
|
| 140 |
echo "* Contents of id_rsa of Admin:"
|
| 141 |
cat /home/admin/.ssh/id_rsa
|
|
|
|
| 41 |
fix_admin_permissions() {
|
| 42 |
echo "* Fixing permissions for 'admin' user *"
|
| 43 |
chown -R admin:admin /home/admin || { echo "Failed to change ownership"; exit 1; }
|
| 44 |
+
chmod -R 777 /home/admin || { echo "Failed to set permissions"; exit 1; }
|
| 45 |
}
|
| 46 |
|
| 47 |
# Function to generate SSH keys for 'admin' user if missing
|
|
|
|
| 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 755 /home/admin/.ssh || { echo "Failed to set .ssh directory permissions"; exit 1; }
|
| 54 |
+
chmod 755 /home/admin/.ssh/id_rsa || { echo "Failed to set private key permissions"; exit 1; }
|
| 55 |
+
chmod 755 /home/admin/.ssh/id_rsa.pub || { echo "Failed to set public key permissions"; exit 1; }
|
| 56 |
fi
|
| 57 |
}
|
| 58 |
|
|
|
|
| 61 |
if [ ! -f /home/admin/.ssh/authorized_keys ]; then
|
| 62 |
echo "* Adding public key to authorized_keys for 'admin' user *"
|
| 63 |
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 755 /home/admin/.ssh/authorized_keys || { echo "Failed to set authorized_keys permissions"; exit 1; }
|
| 65 |
fi
|
| 66 |
}
|
| 67 |
|
|
|
|
| 127 |
#eval $(ssh-agent -s) || { echo "Failed to start SSH agent"; exit 1; }
|
| 128 |
|
| 129 |
# Ensure SSHD config is correctly set up
|
| 130 |
+
#echo "* Configuring SSHD *"
|
| 131 |
+
#echo "UseKeychain yes" >> /home/admin/.ssh/config
|
| 132 |
+
#echo "AddKeysToAgent yes" >> /home/admin/.ssh/config
|
| 133 |
|
| 134 |
# Restart SSH service
|
| 135 |
#service ssh restart || { echo "Failed to restart SSH service"; exit 1; }
|
| 136 |
|
| 137 |
|
| 138 |
+
#add_ssh_key_to_agent
|
| 139 |
|
| 140 |
echo "* Contents of id_rsa of Admin:"
|
| 141 |
cat /home/admin/.ssh/id_rsa
|