This bash script establishes an SSH connection and maps a specific remote server's port to a local port on your machine. This is useful when you want to securely access a remote service like database.
-
Clone the script:
git clone https://github.com/cemre-2187/ssh-tunnel-db-connection.git cd ssh-tunnel-db-connection
-
Edit the script:
nano dbConnection.sh
Modify the default settings for security reasons:
# Target SSH server's IP address server_ip="0.0.0.0" # Target remote port number server_port="5432" # Target local port number local_port="5433" # Username username="your_username" # Password password="your_password"
-
Save and exit the script.
-
Run the script:
sh dbConnection.sh
This command will open the specified SSH connection and enter the password.
-
You can now access the remote service on your local machine using the specified (!!!Important)local port.
- This script should only be used in a secure environment.
If you encounter any issues or want to contribute to the development, please open an issue or submit a pull request.