The hidden potentials of working in Linux

By Andy Mornes | 09/15/2008 - 4:50pm

Working professionally with Linux has given me the opportunity to learn and discover a few tips and tricks that might not have have learned at home.

------------------------------------------------------------------------------
I can be a forgetful person sometimes. When I arrive at work, I would usually forget to sign on to an instant messenger until about 12:30. I thought, I'm using Linux, I should be able to remind myself with a popup message, or something like that. Then I got an idea; Instead of reminding myself to sign on, why not just have it sign me on automatically? I then setup 2 different cron jobs (displayed below). The first, to start pidgin in the morning a little later than when I usually get in, and the second, to kill pidgin at the end of the day, so I'm not available all night. I also had to set the display variable, otherwise it doesn't start correctly since it is a gui program. There's probably a better way to do this, but it works for me.

Here's my cron file:
# m h  dom mon dow   command
30 9 * * mon-fri DISPLAY=:0 /usr/bin/pidgin
0 18 * * mon-fri killall pidgin

------------------------------------------------------------------------------

Another cool trick I learned is to login to my work machine from home without needing any special routing setup or installing any special software, or anything. Just good old SSH. This is a trick (I believe it's called forwarding/reverse SSH) that should work for most people if you are running Linux. Basically, I want to be at home and be able to ssh into work. I also purchased a domain that I use so that I don't have to remember my IP address at home.

In my command, I want to use -p 9999, so I can connect to my ssh-server running on port 9999, then I use the -R switch, which tells it to setup the forwarding connection. The set of 3 values after the -R switch are probably the hardest to get straight (see the X1, X2, etc). Finally, I use my destination address, which is my house.

The home machine:
Available via the domain (let's imagine): andyshouse.com
ssh-server is running on port: 9999

The work machine:
Available via: Nothing (that's the problem)
ssh-server is running on port: 22

The basic command I use:
ssh -p <X1> -R <X2>:<X3>:<X4> <X5>

example.) (Note: I'm using the same user: andy, on both machines)
andy@work:~$ ssh -p 9999 -R 12345:localhost:22 andyshouse.com

Then.)
andy@home:~$ ssh -p 12345 localhost

X1 => port that my home ssh-server is running on
X2 => port to use on the home server
X3 => name of the computer to forward to (I want the computer I'm running on now, my work computer)
X4 => port to forward to (I'm running ssh-server on the default port 22, since it's not open to the world)
X5 => computer to start the service on (my home computer)

After all that work, when I get home, I can use ssh and connect to my localhost on port 12345. I will then be prompted for my work computer's password. If I can manage to remember it and type it correctly, I will be connected directly to work. I can then go about doing/checking whatever I needed to on my work computer. Lastly, additional details can be found on the ssh man page.

See a list of our other blogs.
 

Recent blogs by Andy Mornes

A Twitter Memo: Auto Responding with PHP - 03/09/2010 - 4:54pm
Twitter continues to becoming more and more popular these days, especially for businesses. As a business, you want to keep your followers interested, and in-tune with all... read more

Setting up a redundant email server - 10/05/2009 - 10:32am
In the past few weeks, we have seen an increase in the amount of emails being sent through the CATS system. In response to this increase, I was assigned the task of... read more

Search and Import LinkedIn Profiles into CATS - 09/09/2009 - 4:33pm
There's no shortage of requests for LinkedIn integration. We're proud to announce that as of today, via our Firefox toolbar, you can now import LinkedIn profiles, resumes... read more