The UpFront Section


Tech Tip

If you run a lot of terminal tabs or scripts that all need to make OpenSSH connections to the same server, you can speed them all up with multiplexing: making the first one act as the master and letting the others share its TCP connection to the server.

If you don't already have a config file in the .ssh directory in your home directory, create it with permissions 600: readable and writeable only by you.

Then, add these lines:

Host *
   ControlMaster auto
   ControlPath ~/.ssh/master-%r@%h:%p

ControlMaster auto tells ssh to try to start a master if none is running, or to use an existing master otherwise. ControlPath is the location of a socket for the ssh processes to communicate among themselves. The %r, %h and %p are replaced with your user name, the host to which you're connecting and the port number—only ssh sessions from the same user to the same host on the same port can or should share a TCP connection, so each group of multiplexed ssh processes needs a separate socket.

To make sure it worked, start one ssh session and keep it running. Then, in another window, open another connection with the -v option:

~$ ssh -v example.com echo "hi"

And, instead of the long verbose messages of a normal ssh session, you'll see a few lines, ending with:

debug1: auto-mux: Trying existing master

Pretty fast.

If you have to connect to an old ssh implementation that doesn't support multiplexed connections, you can make a separate Host section:

Host antique.example.com
   ControlMaster no

For more info, see man ssh and man ssh_config.

Tech Tip

You can use the convert command that comes with ImageMagick to extract parts of an image.

You can cut out a 100-pixel-wide chunk from somewhere in the middle of an image:

$ convert -crop 100x+0+0 orig/wrapperbg775.gif slice0.gif
$ convert -crop +200+0 orig/wrapperbg775.gif slice1.gif
$ convert +append slice0.gif slice1.gif wrapperbg675.gif

You can duplicate a 100-pixel-wide chunk from somewhere in the middle of an image:

$ convert -crop 100x+100+0 orig/wrapperbg775.gif slice100.gif
$ convert +append slice0.gif slice100.gif slice 100.gif 
 ↪slice1.gif wrapperbg875.gif

Note that there was no need to specify the height of the image in any of the above commands. If you need to adjust the height instead of the width, the steps are similar, but use -append instead of +append to paste the slices vertically.

Tech Tip

Occasionally, you need to process a number of files—some of which have been compressed and some which have not (think log files). Rather than running two variations, one compressed and one not, wrap it in a bash function:

function data_source ()
 local F=$1

 # strip the gz if it's there
 F=$(echo $F | perl -pe 's/.gz$//')

 if [[ -f $F ]] ; then
   cat $F
 elif [[ -f $F.gz ]] ; then
   nice gunzip -c $F

which nicely allows:

for file in * ; do
 data_source $file | ...

Whether you're dealing with gzip'd files or uncompressed, you no longer have to treat them differently mentally. With a little more effort, bzip files also could be detected and handled.


White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState