Corporate Firewall – SSH and port 443 goodness

Things you’ll need; (basic instructions)
SSH – either Linux or Open SSH for windows (set this up first and ensure its working!). I have only used Linux, so i do not know the details of setting up a Open SSH box on windows (good luck).

Router with pinhole or port forwarding abilities. — forward your external 443 port to internal 22 on your SSH box

Putty.exe – use this to test your SSH connection locally (you should be able to connect on port 22 locally or 443 externally)

Your home IP – setup a dyndns account on one of the free services available on the web (either use your router if it has it or get a dyndns client that runs on your ssh box) — i use dyndns.org

Putty is the client side device that you will use when you are not local to your network. If you are connecting to your SSH box from external (i.e. at work) then you’ll need to configure a SSH connection profile to connect on port 443. If you have a proxy at work (which you will most probably have) you need to ensure you have filled out your proxy address and authentication details — select HTTP then enter your username / password. Then try to connect.

When you can successfully connect to your SSH box from work via 443 you can then create SSH tunnels. Under SSH on putty there is a tunnels option. This is where you can forward local ports to your remote ports… for example – 127.0.0.1:82 –> 192.168.0.10:3389. Then if you fire up RDC you can connect to your remote machine via 127.0.0.1:82

Simple? — if i haven’t made a specific part clear please ask any questions and i’ll try to make it easier to follow

Linux – Installing VirtualBox additions

The following works on CentOs / Fedora / redhat etc… 

Logon to your distro. The packages you need are the kernel-devel.i686, kernel.i686 (if not the latest), and gcc.i386 (complier)

yum -y install kernel.i686 gcc.i386

reboot as the kernel needs to load, then logon again install the kernel dev; 

yum -y install kernel-devel.i686

Now you want to present the virtualbox additions to the cdrom drive on your distro. Click “install additions” on the virtualbox guest console. 

then back on the box mount the cdrom to a directory (make one if you dont have one avail) 

mkdir /mnt/cdrom

mount /dev/cdrom /mnt/cdrom 

Now go to the newly mounted cdrom drive and find the installation;

cd /mnt/cdrom 

Execute the installer, and if all goes well reboot. Services should auto start and sync your time etc. 

./VBoxLinuxAdditions-x86.run

reboot

logon and check your time; 

date

Done.

VMware Server 2.0 – Infrastructure Client

One thing i like about vmware server 2.0, is that you are not forced to use the web console in all cases.

If you are lucky enough to have access to VMware Infrastructure Client 2.5 you can connect via it using the following syntax at the logon screen;

IP address / Name : http://192.168.9.100

If you enter a URL in the host field, use your root and correct password you should be able to logon without issue. Welcome to a nice fast GUI admin console.

Linux – crontab

Time to schedule some tasks!

First you need to make sure your in the /etc/cron.d/cron.allow file. If you are not SU to root and add yourself into it.

Now to create your new crontab file;

crontab -e

You are in vi in your newly created crontab file (note if you do not have access to do this it will say so)

Now, i’m no expert at using vi, but if you press i you will go into insert mode. Do this, then type the cron job details. A typical cron job will look like this

0 4 * * * /export/home/user/backup.sh

so there are five slots before the command you want to run. They are: min, hour, day, month, day-week. So my example above will run at 4am every day. See below for more detail.

once you have entered the line press ESC then type :wq to save and quit.

To confirm the job has been saved successfully in cron type this command;

crontab -l  this will show you your current scheduled tasks, it should output the above job.

In OpenSolaris the crontab files are located at /var/spool/cron/crontabs/ they are named after the specific user. Sometimes its easier to go there than to use vi, but make sure your permissions are all set correctly before editing any system files.

In some distros there are folders like /etc/cron.daily/ which run any scripts inside them on a schedule matching the folder name.

This is a bit more on the format of the 5 timings within the crontab file;

*     *   *   *    *  command to be executed

|     |     |     |     |
|     |     |     |     +—– day of week (0 – 6) (Sunday=0)
|     |     |     +——- month (1 – 12)
|     |     +——— day of month (1 – 31)
|     +———– hour (0 – 23)
+————- min (0 – 59)

Update

@reboot is also another very handy cron modifier. I use the following quite a lot…
@reboot /bin/sleep 600 ; /path/to/your/your_program@reboot /bin/sleep 600 ; /path/to/your/your_program