Tuesday, April 23, 2013

Backing Up The Database via SSH/Telnet



In order to back up your database via SSH or Telnet you will require 2 things:

1) SSH or Telnet access to your site. You will need to check with your hosting company to see if this is available.

2) An SSH/Telnet Client, such as PuTTy.

Open your SSH/Telnet client and log into your website. The command line prompt you will see will vary by OS.
For most hosting companies, this will bring you into the FTP root folder.

Type in the following to create a backup in the current directory:

mysqldump --opt -Q -u dbusername -p databasename > backupname.sql

Or to create a backup in a separate directory (signified by /path/to/) type:

mysqldump --opt -Q -u dbusername -p databasename > /path/to/backupname.sql

You will be prompted for the database password. Enter it and the database will backup.

If your hosting company has you on a remote MySQL server, such as mysql.yourhost.com, you will need to add the servername to the command line. The servername will be the same as in your config.php. The command line will be:

Current directory:

mysqldump --opt -Q -h servername -u dbusername -p databasename > backupname.sql

Separate directory:

mysqldump --opt -Q -h servername -u dbusername -p databasename > /path/to/backupname.sql

You can then, if you wish, download the backup to your home computer.

Thursday, April 18, 2013

SSH Tunnel in 30 Seconds (Mac OSX & Linux)



Some days, I wonder why VPN’s are really necessary when we can just use an SSH tunnel.
If you’re on Mac or a flavour of Linux, this SSH tunnelling tutorial is for you.
“A secure shell (SSH) tunnel consists of an encrypted tunnel created through a SSHprotocol connection. Users may set up SSH tunnels to transfer unencrypted traffic over a network through an encrypted channel.” – Wikipedia

Launch an SSH tunnel

To initiate your SSH tunnel, simply open Mac OSX / Linux Terminal and connect to your remote server via SSH with the following flags:

ssh -D 8080 -C -N -p 5050 username@example.com
 
This will launch our SSH tunnel on port 8080 and route all traffic (securely) through the server at example.com.

Browse the Web with Your SSH Tunnel (Chrome)

Now, let’s start browsing the web using our new SSH tunnel.
Mac OSX:
  1. Open Google Chrome
  2. Select ‘Chrome’ up the top left
  3. Select ‘Preferences’
  4. Select ‘Show advanced settings…’
  5. Select ‘Change proxy settings…’
  6. Select ‘SOCKS Proxy
  7. Enter ’127.0.0.1′
  8. Enter port ’8080
  9. Save changes by selecting ‘OK’
Fedora Linux:
  1. Open Google Chrome
  2. Select the wrench icon on the top right
  3. Select ‘Settings’
  4. Select ‘Show advanced settings…’
  5. Select ‘Change proxy settings…’
  6. Select ‘SOCKS Proxy’
  7. Enter ’127.0.0.1′
  8. Enter port ’8080′
  9. Save changes by selecting ‘OK’
Search Google for ‘my ip’ and take a look at what your IP address is now. Cool right? 

Exiting the SSH Tunnel

To exit the SSH tunnel, simply disable the SOCKS proxy within your browser.
Hope this helps, let me know if you have any suggestions in the comments below!

Incoming search terms:

  • set up pptp web tunnel ssh on linux
  • mac shh tunneling browser
  • ssh -l tunnel connection