Using Trickle to Control Bandwidth Use in Any Program

There are a number of reasons why you would want to control how much bandwidth any given program is able to use. This can be done in a couple different ways, including options right with in the software, or through a software or hardware firewall. A great little program for managing bandwidth use is Trickle. Trickle runs completely in userspace, which means we don’t need to mess with a firewall, or even need root access.

If you’re on Ubuntu/Debian you should be able to install Trickle using

sudo apt-get install trickle

Now that you’ve got Trickle installed just use it before any network command to limit its bandwidth. Quite self-explanatory -u specifies upload and -d download.

trickle -u 25 -d 100 myCommand

The reason I first started using Trickle was so I could use Rsync and SCP to copy/backup files on my computer without negatively affecting the speed of my Internet connection. I have a fairly limited upload speed and this is an example of how I would limit the upload speed to 100 KB/s when backup up a folder with Rsync. Please note that when using Trickle with Rsync you have to use the -e option.

trickle -a -e "trickle -u 100 ssh" myFiles

It is even easier using Trickle with SCP where all you would need to do is use:

trickle -u 100 scp

Simplifying Managing Your SSH Connections by Using an SSH Config File

I’ve been using Linux as my primary operating system for over five years, and spent a good deal of time with it before that time. It’s only been within the last year or so that I’ve really begun to explore and enjoy working from the Linux/Unix command line. It’s greatly simplified my work flow when it comes to many tasks, and it seems I spend the majority of my time either in a command line or web browser now a days. Now that nearly 100% of the time when I’m working on a remote system, whether it is a server, Linux/Unix PC, or networking equipment, I’m usually connecting with SSH.

SSH is an incredibly powerful tool that can be used for everything from remote terminal access, to running entire graphical programs over a network. For me though remembering and having to type in all the IP Addresses, DNS Names, usernames and port numbers for all the SSH connections I use daily can be a real pain. That’s why setting up your own SSH config file can save huge amounts of time and effort in your day-to-day work.

This tutorial will be much easier to follow if you have a basic understanding of how to use SSH.
The steps in this tutorial were performed on Ubuntu 11.10. You may need to modify some steps depending on what system you are running.

GUI Version

1. Open Gedit (or your editor of your choice)
2. Click File->Save
Go to your home folder, and display hidden files by hitting CTRL+H on your keyboard.
Open the .ssh folder and save your new file as config

Command Line Version

1. First open up the terminal on your Linux/Unix based system.
2. Use vi (or any editor of your choice)

vi ~/.ssh/config

3. There are many options that you can set in a config file, but we will go over the settings that I usually use. Here’s an example:

Host myServer

User root
Port 222

Host myDesktop


This example shows two different SSH connections and their different options. The first is an example server that we want to connect to at, with the username root, and where the SSH service is running on the non-standard port 222. The second is an example of a computer on your local network. As you can see we used a local IP address instead of a DNS name, also we didn’t bother setting a port number since it is running on the standard port 22. Also because in this example I’m assuming your connecting from another computer you own at the location there is no username set since I’m assuming you are using the same username on both computers you’re using for the connection.

4. Other options that I often use would be ServerAliveInterval, and ServerAliveCountMax.

Host myServer

User root
Port 222
ServerAliveInterval 30
ServerAliveCountMax 120

Host myDesktop

ServerAliveInterval 30
ServerAliveCountMax 120

This example would keep your SSH connection live for an hour by refreshing the connection every 30 seconds. This can be handy if you don’t want to be logged out every time you step away from your keyboard.

With your new SSH Config file instead of having to type in:

ssh -p 222 

You can just use:

ssh myServer

Hope this little trick saves you as much time as it has saved me.

Running RSYNC on a non-standard port

When it comes to using and managing Linux/Unix based systems RSYNC has consistently proven itself a lifesaver for me. It is by far the easiest, safest, and most reliable way to copy, sync, and backup files. I’ve even started using it on Windows machines with Cygwin when I need a good way to transfer large amounts of data between drives. Now when using RSYNC to backup computers across networks I often come across situations where SSH is running on a non-standard port, something other than Port 22, and I need to figure out a way to let RSYNC know what port to run on.


Now when you’re just logging in with SSH it is as easy as using:

ssh -p 2222 matthew@

instead of:

ssh matthew@

and with SCP all you need to use is:

scp -P 2222 matthew@ /home/matthew/localFolder/

instead of:

scp matthew@ /home/matthew/localFolder/

When you are using RSYNC though things are a bit different. You need to use the -e parameter like this:

rsync -avz -e "ssh -p 2222" matthew@ /home/matthew/localFolder/

Just like that you can run RSYNC on whatever port you need to get the job done. If you’ve never heard of RSYNC or aren’t using it and do any type of work involving file transfers/backups I highly recommend you check it out!