Archive for the ‘How-To’ Category

Kicking it with some switches

With a recent need to update and configure switches at the office.  I used a few simple steps to make this all happen.   These steps require you setup a closed network with a DHCP Server and TFTP Server and connect all switches to this network.

TFTP Software Update to ProCurve Switch

Connect to switch via serial cable to access to the console.  Here you can use the CLI to send instructions to the switch.

Execute the copy command as shown:

# copy tftp flash <ip of the tftp server> <software filename ex. W_14_28.swi>

You will see the following response:  The primary OS image will be deleted.  Continue [y/n]? Y

This will update the primary software version.    The secondary can be update at a later time.

TFTP Configuration Settings to ProCurve Switch

Connect to switch via serial cable to access to the console.  Here you can use the CLI to send instructions to the switch.

To take a backup of the configuration file to a TFTP server type:

copy startup-config tftp <ip of the tftp server> <filename>

To restore the switch’s configuration file, you can use TFTP for the upload:

copy tftp startup-config <ip of the tftp server> <filename>

Note: that the switch will reboot whenever you upload the configuration file from a TFTP server

HowTo: Make a Windows 7 USB Flash Install Media while in Linux

Recently I had a need to install Windows 7 on a computer and I was out of DVD media to use. The only media I had was a 8GB USB Thumb drive. I have done this many of time in Windows itself with various of tools and eve manually. Now I do it in Linux also.

Here is a small list of items one would need:

  1. Windows 7 ISO Media
  2. 4GB or larger USB Pen Drive
  3. And Linux Install with root access (sudo, will work fine)

Open up a terminal and location the device that your USB drive is mounted to.

In my situation I had my USB Pen drive mounted at the following location /media/usb, the device was location at the following location /dev/sdb1

I first unmounted the drive using the following command:

sudo umount /dev/sdb1

I then changed directories until I was in the path of my Windows 7 .ISO image. This is not necessary; I do this out of habit. I then use the ‘dd’ command to copy the .ISO image to the USB Device (USB Pen Drive). Example: dd if=windows7.iso of=/dev/sdb1

After a short while the image is fully copied to the USB Pen Drive and you can then boot from this device to begin the Windows 7 Install

cently I had a need to install Windows 7 on a computer and I was out of DVD media to use. The only media I had was a 8GB USB Thumb drive. I have done this many of time in Windows itself with various of tools and eve manually. Now I do it in Linux also.

Here is a small list of items one would need:

  1. Windows 7 ISO Media

  2. 4GB or larger USB Pen Drive

  3. And Linux Install with root access (sudo, will work fine)

Open up a terminal and location the device that your USB drive is mounted to.

In my situation I had my USB Pen drive mounted at the following location /media/usb, the device was location at the following location /dev/sdb1

I first unmounted the drive using the following command:

sudo umount /dev/sdb1

I then changed directories until I was in the path of my Windows 7 .ISO image. This is not necessary; I do this out of habit. I then use the ‘dd’ command to copy the .ISO image to the USB Device (USB Pen Drive). Example: dd if=windows7.iso of=/dev/sdb1

After a short while the image is fully copied to the USB Pen Drive and you can then boot from this device to begin the Windows 7 Install

No more ‘thumbs.db’ for me

I fist must state that these steps I am about to provide are to be used by those of us whom are neurotic about files stored on the file system.  While there are some good security reasons one may want to do this; I do what I am going to describe because I feel they clutter up my drive and dislike seeing or even knowing they are there.

My default windows (Win7 in my case) generation a file called thumbs.db in the folder that I am working in. The file thumbs.db is a thumbnail cache, used to store a small (thumbnail) image for Windows Explorer thumbnail view.  The idea is to speed up the display of images as the smaller image does not need to be recalculated (regenerated) every time the use views the contents of a folder.

So what do I do about it?  At first I use to delete them; that only makes me happy for that moment, as they come back like some kid with acne who pops one pimple to later show up again.

By using the Local Group Policy Editor I have found a better way to keep these guys /or gals from coming back.  You can start the Local Group Policy Editor by typing gpedit.msc in the search or run text box.

The Editor will open to the top-level Local Computer Policy, so you will have to expand the User Configuration item in the left-side pane of the Editor window.  Drill down through Administrative Templates, then Windows Components, and click on the Windows Explorer item.  Near the top of the list in the right-hand pane of the Editor window you will find the setting “Turn off the caching of thumbnails in hidden thumbs.db files”

To edit this policy setting, either double-click on the title of the policy or click the link titled “Edit Policy Setting” to the left of the setting list after you select the policy.  Check the “Enabled” button and click OK

Close the Local Group Policy Editor.  You may want to unhide all hidden file sand system files and do a search for the files and delete them.  And now I can be happy knowing they are gone.

Mounting a remote file system using ssh (sshfs)

For some time I have always used tools such as scp sftp to copy files between Linux based systems. Until the growing need to have this process simplified.  I recently fell in love with Linux all over again with the new release of Ubuntu.  I always had known it was possible but never had the direct need to mount ssh file systems remotely.  This is where some Google searching and SSHFS and FUSE came into play on my home systems.

So what are some things I found out?  Well for one; as long as I have SSH access to a remote system I can use SSHGS to mount and use the remote directories as if they were on my local system.  SSHGS require no special software on the remote host so this is good in a hosted situation where you have no control over what gets installed.

This is where I give you the * filler * info on SSHFS.

SSHFS is built upon the FUSE user-space file-system framework project.  FUSE allows user-space software; in my case SSH to present a file-system that is virtually interfaced to the end use.  SSHFS connect to the remote system and does all the necessary operations to provide the look and feel of a regular file-system.

So now what?

First we need to start off by installing sshfs if not already installed.  I am using Ubuntu like I had mentioned above so by typing sudo apt-get install sshfs that installs all I need and supporting requirement.

The fun part.

Create a local directory where you want the files mounted.  This process is similar to mount smb shares from another system.  In my example I will be mounting the directory /home on the remote server to a local path on my system:

“sudo mkdir /mnt/remotehome1”

“sudo sshfs jermsmit.com:/home /mnt/remotehome1

You can also change the owner of the new directory by typing chown ‘yourusername’ /mnt/remotehome1

Please note that the /mnt/remotehome1 directory must exist and be owned by you, so keep in mind when you make (for example) /mnt/remotehome1/ you should assign permissions to your user so that you may access it.

To unmounts the directory, you can use the command fusermount –u.  Example fusermount –u /mnt/remotehome1.  If you get a message about the path being in use make sure that you have change directory out of this path and try again.

That’s about it.  Very clean and simple, and next time I hope to write about setting this up in such a way its auto mounted on startup (aka persistent), but for now this gets the job done.

Configure Firefox to use SSH tunnel for DNS

If you are using SSH to tunnel your web traffic, to keep your information private, you might be vulnerable to a DNS man-in-the-middle attack.  If your DNS requests aren’t tunneled, the operator of the hostile (or locked down) network can still see where you are navigating to on the web when your client makes DNS requests to resolve hostnames to IP addresses.
For these reasons (and for many others), it’s a good idea to tunnel DNS through your SSH tunnel too.  This can be done very easily in Firefox.

In the Firefox URL address bar, enter “about:config“.
In the Filter text field, enter “network.proxy.socks_remote_dns“.
Double-click “network.proxy.socks_remote_dns” to set the value to true.

HowTo: VMware Tools in Ubuntu 10

Again I am working on my server; a virtual machine powered by VMware.  I recalled that I did not have the tools installed; also the virtual server console gave me an additional reminder.  So I decided to install.

There are a few things to do before installing.  First we need to make sure our server (Ubuntu) has compiler tools installed.  Then we must mount the virtual cd containing the VMware drivers and software tools for Linux.  From the command line terminal (I recommend doing this from the local console) as the network tools will drop you from the SSH connection.

Steps

sudo aptitude install build-essential linux-headers-$(uname -r)
cp -a /media/cdrom/VMwareTools* /tmp/
cd /tmp/
tar -vxzf VMwareTools*.gz
cd vmware-tools-distrib/
sudo ./vmware-install.pl

You will be asked a bunch of questions; I personal just accept the defaults and (press ENTER) to each one of them.  When completed, I reboot my server and that is it.  Tools are installed.

How I got my eth0 back

After a recent Ubuntu Linux (server) installation inside in a virtual machine, I decided to move the virtual machine to new a new host where I can run it.  After the move I noticed that I could no longer connect to my system via the IP I had assigned.  So the story begins.

With the discovery that I no longer had network connectivity, I did an ‘ifconfig’ and noticed that my eth0 was missing.  So, I tried to force it to start by issuing the command ‘ifup eth0’ and go the following error:

eth0: ERROR while getting interface flags: No such device…
SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
eth0: ERROR while getting interface flags: No such device
Bind socket to interface: No such device
Failed to bring up eth0

I did some searching, as I have run into this issue in my past and could not remember for the life of me what I needed to do to correct this problem (the right way).  The method I used in the past was to edit /etc/network/interfaces and change iface eth0 inet (static or dhcp) to eth1  This would change my static or dynamic settings to use the new interface…  This is not what I wanted to; “lazy admin approach”.

What I did do is… wait! Here is some background info:  When a Virtual Machine starts up, it generates a new MAC address and a new UUID for the guest system. My system had already known of a MAC address and thus made a new one.

Back to what I did to correct my problem

Locating the file /etc/udev/rules.d/70-persistent-net.rules, I removed the former MAC address info and modified the new one, changing the existing eth1 to eth0, and issued a restart

Example:
# PCI device 0×8086:0x100f (e1000)
SUBSYSTEM==”net”, DRIVERS==”?*”, ATTRS{address}=”[bad mac]“, NAME=”eth0″

UAC from Windows 7 Command Line

UAC (User Account Control) is the most obnoxious, nagging  windows that will drive you crazy and frustrate you while using Windows 7 or Vista.

One way to stop being annoyed is to disable it.  However doing so will make your computer less secure.  I in no way recommend anyone disable UAC, but I will provide a quick way to disable and enable via the command line.

Disable UAC

C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

Enable UAC

C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f

Both require a reboot to take effect.

Return top