Push
This commit is contained in:
79
set-postgres-password.sh
Executable file
79
set-postgres-password.sh
Executable file
@@ -0,0 +1,79 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Interactive PostgreSQL Password Setup Script
|
||||||
|
|
||||||
|
echo "=========================================="
|
||||||
|
echo "PostgreSQL User Password Setup"
|
||||||
|
echo "=========================================="
|
||||||
|
echo ""
|
||||||
|
echo "Available users:"
|
||||||
|
echo " 1. postgres (superuser - recommended)"
|
||||||
|
echo " 2. skyartapp"
|
||||||
|
echo " 3. songlyric_app"
|
||||||
|
echo " 4. songlyric_user"
|
||||||
|
echo ""
|
||||||
|
read -p "Select user number (1-4): " user_choice
|
||||||
|
|
||||||
|
case $user_choice in
|
||||||
|
1)
|
||||||
|
username="postgres"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
username="skyartapp"
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
username="songlyric_app"
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
username="songlyric_user"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid choice. Exiting."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Setting password for user: $username"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Prompt for password (hidden input)
|
||||||
|
read -s -p "Enter new password: " password
|
||||||
|
echo ""
|
||||||
|
read -s -p "Confirm password: " password_confirm
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [ "$password" != "$password_confirm" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Error: Passwords do not match!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$password" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Error: Password cannot be empty!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the password
|
||||||
|
echo ""
|
||||||
|
echo "Setting password..."
|
||||||
|
sudo -u postgres psql -c "ALTER USER $username PASSWORD '$password';"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "=========================================="
|
||||||
|
echo "Success! Password set for user: $username"
|
||||||
|
echo "=========================================="
|
||||||
|
echo ""
|
||||||
|
echo "You can now use these credentials in pgAdmin 4:"
|
||||||
|
echo " Host: 192.168.10.130"
|
||||||
|
echo " Port: 5432"
|
||||||
|
echo " Username: $username"
|
||||||
|
echo " Password: [the password you just entered]"
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "Error: Failed to set password!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
62
setup-postgres-remote-access.sh
Executable file
62
setup-postgres-remote-access.sh
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# PostgreSQL Remote Access Setup Script
|
||||||
|
# This script configures PostgreSQL for remote access from Windows pgAdmin 4
|
||||||
|
|
||||||
|
echo "=========================================="
|
||||||
|
echo "PostgreSQL Remote Access Setup Complete!"
|
||||||
|
echo "=========================================="
|
||||||
|
echo ""
|
||||||
|
echo "Server IP: 192.168.10.130"
|
||||||
|
echo "Port: 5432"
|
||||||
|
echo ""
|
||||||
|
echo "Available Databases:"
|
||||||
|
echo " - skyartshop (owner: skyartapp)"
|
||||||
|
echo " - church_songlyric (owner: postgres)"
|
||||||
|
echo " - postgres (default database)"
|
||||||
|
echo ""
|
||||||
|
echo "Available Users:"
|
||||||
|
echo " - postgres (superuser)"
|
||||||
|
echo " - skyartapp"
|
||||||
|
echo " - songlyric_app"
|
||||||
|
echo " - songlyric_user"
|
||||||
|
echo ""
|
||||||
|
echo "=========================================="
|
||||||
|
echo "Next Steps:"
|
||||||
|
echo "=========================================="
|
||||||
|
echo ""
|
||||||
|
echo "1. Set password for postgres user (if not already set):"
|
||||||
|
echo " sudo -u postgres psql -c \"ALTER USER postgres PASSWORD 'your_secure_password';\""
|
||||||
|
echo ""
|
||||||
|
echo "2. Set password for other users if needed:"
|
||||||
|
echo " sudo -u postgres psql -c \"ALTER USER skyartapp PASSWORD 'your_secure_password';\""
|
||||||
|
echo ""
|
||||||
|
echo "3. In pgAdmin 4 on Windows, create a new server:"
|
||||||
|
echo " - General Tab:"
|
||||||
|
echo " Name: Ubuntu Server PostgreSQL"
|
||||||
|
echo ""
|
||||||
|
echo " - Connection Tab:"
|
||||||
|
echo " Host: 192.168.10.130"
|
||||||
|
echo " Port: 5432"
|
||||||
|
echo " Maintenance database: postgres"
|
||||||
|
echo " Username: postgres (or any user you set password for)"
|
||||||
|
echo " Password: [the password you set]"
|
||||||
|
echo " Save password: [check if desired]"
|
||||||
|
echo ""
|
||||||
|
echo "4. Click Save to connect!"
|
||||||
|
echo ""
|
||||||
|
echo "=========================================="
|
||||||
|
echo "Security Notes:"
|
||||||
|
echo "=========================================="
|
||||||
|
echo "- Remote access is allowed from 192.168.10.0/24 network"
|
||||||
|
echo "- All connections use scram-sha-256 authentication"
|
||||||
|
echo "- Firewall (ufw) is currently inactive"
|
||||||
|
echo "- Backups saved to:"
|
||||||
|
echo " /etc/postgresql/16/main/postgresql.conf.backup"
|
||||||
|
echo " /etc/postgresql/16/main/pg_hba.conf.backup"
|
||||||
|
echo ""
|
||||||
|
echo "To restore original configuration:"
|
||||||
|
echo " sudo cp /etc/postgresql/16/main/postgresql.conf.backup /etc/postgresql/16/main/postgresql.conf"
|
||||||
|
echo " sudo cp /etc/postgresql/16/main/pg_hba.conf.backup /etc/postgresql/16/main/pg_hba.conf"
|
||||||
|
echo " sudo systemctl restart postgresql"
|
||||||
|
echo ""
|
||||||
Reference in New Issue
Block a user