Jul 30

I have to setup a couple of hundred laptops carried by sales folks in the field to connect to a new WPA2-PSK network for work.  Fortunately, windows XP has a nice little utility that lets you automate creating a new wireless connection. You’ll need a USB thumbdrive for a little bit to make this work, but you won’t need to distribute it.

  • In Control Panel, Run the Wireless Network Setup Wizard and enter in all of your network specifics.
  • When prompted, choose the”Use a USB flash drive” Method. Make sure you have a flash drive plugged into your computer.
  • Pick the drive letter and hit next,  once it has copied the files over, you can just hit cancel and exit out of the wizard.

On your thumbdrive you now have two files (setupsnk.exe and AUTORUN.inf) as well as a directory (SMRTNTKY) with various files in it. If you wanted to, you could distribute this thumbdrive as is and just have people click on the setupsnk.exe to configure their machines. I need to email these settings out, so I did this instead.

  • Create  a folder, C:\Wireless
  • copy  those two files and the entire folder into C:\Wireless
  • create a batch file called “Install_Wireless.bat” and place it into C:\Wireless
  • put the following in that batch file

SET CUR_DIR=%cd%
subst z: “%CUR_DIR%”
chdir /D Z:
Z:\setupsnk.exe
sleep 60
subst /D Z:

The batch file just creates a temp drive (z) that points to C:\wireless, the current executing bat files directory, changes to that drive and runs the setup. setupsnk assumes that it is being run directly from a drive letter, hence the mapping.  We wait for 60 seconds after the run and then remove the drive mapping assuming that you were able to click the ok button twice in 60 seconds (the whole process takes like 2 seconds).

Now, just zip that all up and distribute it.  The key piece is that everything gets extracted to C:\wireless.   I tried the old Relative paths in batch files trick, but it didn’t work for whatever reason and I’m in a bit of a hurry on this one.  If anyone can get that part working, you would be teh awesome. I get to claim that awesome sauce.   %~dp0 wasn’t working for whatever reason, but %CD% does, so I’ll take it.

Jul 30

I picked up these regex strings awhile back somewhere on the internets and have used them in a couple of perl scripts. Thought they might come in handy.

To filter a string to make sure it’s a valid ip address..
/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/

And this one for mac addresses
/^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/

Extract web address
((?:http|ftp)s?://)?(((([\d]+\.)+){3}[\d]+(/[\w./]+)?)|([a-z]\w*((\.\w+)+){2,})([/][\w.~]*)*)

Jul 29

Unix has been able to authenticate against a central server for a long, long time using LDAP and various other technologies, but Microsoft’s Active Directory is the authentication scheme you are most likely to come across in the enterprise.  Using RHEL (well, centos) it’s an easy setup.

From a command line box, run

authconfig-tui

Select “Use Winbind” under User Information and “Use Winbind for Authentication” under Authentication. I also select “Local authorization is sufficient” which we could argue for a long, long time about. That one is up to you.
When you click next, you’ll need to fill in the blanks with your organizations specific information. You do want to use “ads” as your security model if you are on active directory and put a wildcard (*) in the Domain Controllers field. Next hit Join Domain and enter the credentials for an account that has the rights to join this machine to the domain. Next we need to tweak a few files.
in /etc/samba/smb.conf change

“winbind use default domain=no” to “winbind use default domain=”yes”

If you don’t, you will need to enter your domain every time you log a user into the system like AD/User instead of just logging in as User.
Add

idmap backend = rid

into the authconfig section, right under the “idmap gid =” line. This sets up user and group id mappings to use the AD RID. You want this as long as only one domain will be logging into this server. If users from several AD domains will be logging in, you need to hit google.
In /etc/pam.d/system-auth, add

session required pam_mkhomedir.so skel=/etc/skel umask=0077

To the very end of the file. This creates a home directory for each user when they log into the system if they don’t have one already.
Now just issue a

service winbind restart

and you should be on your way!

Jul 28

Using mailx and uuencode on a unix host, you can send a message from the command line with an attachment like so.

uuencode FILE | mailx -s “test message with an attachment” youraddy@yourhost.com

I add one more step and send a zipped directory to my self every night

zip -j -q -r -/tmp/directory/ | uuencode tmp.zip | mailx -s “test message with a zip attachment” me@me.com

Jul 27

This is a pretty basic one, but I don’t do it enough (or maybe I’m doing it just enough) to remember sometimes.
This works in RHEL/Centos, should work in just about everything else too.

When grub loads up at boot, hit ESC to stop the countdown timer. Now hit “a” to append a line to the boot string. Last, type ” single”, yes that’s SPACE SINGLE, and hit enter. The box will boot without loading any services and dump you to a shell. When you are done, type exit and it should continue booting.

« Previous Entries