Atavism WordPress Server Install – Secured

Introduction

  • Overview of Autossh and its benefits for SSH tunneling.
  • Purpose: Guide on using Autossh for a stable MySQL tunnel between two servers.

Section 1: Installing Autossh

  1. Updating Package Lists:
    • Command: sudo apt-get update.
    • Purpose: Ensures you have the latest package listings.
  2. Installing Autossh:
    • Command: sudo apt-get install autossh.
    • Note: Perform this on both servers.

Section 2: Enabling SSH Tunneling on Remote Server

  1. Editing SSH Configuration:
    • Command: sudo nano /etc/ssh/sshd_config.
    • Addition: Append AllowTcpForwarding yes to the file.
  2. Restarting SSH Service:
    • Command: sudo service ssh restart.
    • Purpose: Apply changes to SSH configuration.

Section 3: Setting Up the SSH Tunnel with Autossh

  1. Establishing SSH Tunnel:
    • Command:
      autossh -M 0 -N -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -L 3306:localhost:3306 remote_user@remote_host
    • Replace remote_user and remote_host with appropriate credentials.
    • Explanation:
      • -M 0: Disables monitoring mode.
      • -N: No command execution on remote.
      • -o options: Keepalive settings for stability.

Section 4: Connecting to MySQL Through the Tunnel

  1. Using MySQL Client:
    • Connect to localhost:3306.
    • Use remote MySQL credentials.
  2. Verification:
    • Test the connection to ensure it’s operational.

Conclusion

  • Recap of setting up and using Autossh for MySQL tunneling.
  • Emphasize the reliability and automatic reconnection features.

Additional Resources

  • Autossh documentation for advanced configurations.
  • SSH and MySQL best practices.

Interactive Elements:

  • Quiz: Test understanding of Autossh setup and SSH tunneling.
  • Hands-on Lab: Practice setting up the SSH tunnel with Autossh.
  • Discussion Board: Share experiences and troubleshoot common issues.

This lesson gives a comprehensive guide to using Autossh for a stable and reliable MySQL tunnel over SSH, ensuring a secure and consistent connection between servers.