Most Internet service provider will try shutdown active Internet connections after a view minutes to prevent their network from streaming videos or other bandwidth killers. This happens often because of some router setting you can’t change. As a web developer your SSH session (and other active connections) will freeze, if you stop working in the terminal window for just 5 minutes or by getting a fresh cop of coffee.
To get rid of this problem you need to change your SSH config file, enter the following inside to the terminalwindow
sudo nano /etc/ssh/ssh_config
and add this setting to the end of the file
Safe your file and start a new SSH session which will stay active because the client sends every 60 seconds a bit of data to the server.
Check also this article for more information.
Follow the instructions below to create and install a SSH public key on your remote server. After you followed these steps your able to login via SSH without entering a password. This is extremely useful for backups with rsync or for other automatic tasks you like to execute.
- Change to your user’s home directory (local system)
- create a pair of private keys
ssh-keygen -f .ssh_key -t rsa -N ''
- *** upload the public key to the remote system using rsync via SSH
rsync -e ssh ~/.ssh_key.pub user@YourServer:key1.pub
- login to your server via SSH using the command line or Putty
(you need to enter your password too)
- check if the .ssh directory exists, if not create it
- add the public key to the user authorized key files
cat key1.pub >> .ssh/authorized_keys
- remove the uploaded key from your home directory (remote system)
- test your new “private” connection
rsync -avz -e "ssh -i .ssh_key" "someFolder" user@YourServer
Now you’re able to access the remote system (YourServer) from your local system without using a password. This tutorial is for Linux only.
*** UPDATE: 12th december 2011
If you can’t create a persistent SSH connection to you backup server this way you need a small workaround:
After the creation of your “local” keys you need to download the “authorized_keys” file from the backup server
rsync -e ssh user@YourServer:.ssh/authorized_keys ~/authorized_keys
(check the exact locations first)
Now add your public key to the downloaded file
cat .ssh_key.pub >> authorized_keys
Upload the modified “authorized_keys” file to the backup server
rsync -e ssh ~/authorized_keys user@YourServer:.ssh/authorized_keys
Remove the downloaded file and test you connection like described in step 8.
You will find on most Linux based web hosts a directory which is called “sites-available” (inside /etc/httpd/ or /etc/apache2/). Create a configuration file with the name “domain.com” for your host and add this code:
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg
CustomLog /var/log/apache2/domain.com-access.log combined
Create the directory for your web host and activate the host with
a2ensite domain.com and reload your apache engine.