Setting Up SSH Tunnels
Introduction
SSH tunnels allow you to securely connect to MySQL databases that are behind firewalls or only accessible via SSH.
When to Use SSH Tunnels
- Database behind firewall
- Remote server access
- Security requirements
- No direct MySQL port access
Setting Up SSH Tunnel
Step 1: Enable SSH Tunnel
- Open connection dialog
- Check "Use SSH Tunnel"
- SSH configuration appears
Step 2: Configure SSH
Enter SSH details:
- SSH Host: SSH server address
- SSH Port: Usually
22 - SSH Username: Your SSH username
- Authentication: Password or private key
Step 3: Configure MySQL
Enter MySQL details:
- MySQL Host: Usually
localhost(through tunnel) - MySQL Port: Usually
3306 - Username: MySQL username
- Password: MySQL password
Step 4: Test Connection
- Click "Test Connection"
- SSH tunnel establishes
- MySQL connects through tunnel
- Save connection
Authentication Methods
Password Authentication
- Select "Password"
- Enter SSH password
- Stored encrypted
- Simple setup
Private Key Authentication
- Select "Private Key"
- Browse to key file
- More secure
- No password needed
Troubleshooting
SSH Connection Fails
- Verify SSH host and port
- Check SSH credentials
- Test SSH connection separately
- Review firewall rules
MySQL Connection Fails
- Verify MySQL host (usually localhost)
- Check MySQL credentials
- Ensure MySQL is running
- Review MySQL user permissions
Best Practices
Security
- Use private keys when possible
- Limit SSH access
- Use strong passwords
- Regular key rotation
Performance
- Keep tunnels active
- Monitor connection health
- Use connection pooling
- Optimize network
Next Steps
- Learn about Connection Settings
- Read User Management guide
- Explore Security features
