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 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 8

I nabbed this one from Lifehacker.   Instead of having to hard code paths in batch scripts you can use the variable %~dp0 to signify the working directory of the script itself.   Now, I usually try not to be a zealot and bash on windows much especially since I started working at a computers that is very windows centric,  but damn man!  One of windows greatest weaknesses is lack of a really good command line and ‘%~dp0′ is a perfect example of that.  Though I will be using that variable in scripts to come :D

If you use “%~dp0″ (sans quotes) in a batch file, this will point to the batch file’s path. For example :

SET MAC=00:00:00:00:00:00
%~dp0mc-wol.exe %MAC%

Apr 21

WMI is microsoft’s attempt at making SNMP “better”. Whether they succeed or fail at that is subjective, but querying wmi from a non windows hosts has been a problem in the past and has required lots of hoops and weird proxies. No more! wmic is a command line wmi client that you can install on linux. On a debian based host, just use

apt-get install wmi-client.

Once installed, a simple test like the following should get you lots of wmi goodies. Just remember that you need to use a valid windows account that has permissions to query wmi for this to work.

wmic -U $DOMAIN/$USER%$PASSWORD //$SERVER “Select * from Win32_Service”

$DOMAIN is your AD domain where your user exists
$USER is your username
$PASSWORD is your users password
$SERVER is the server name

A real world example

jason@workstation:~$ wmic -U AD/jason%ohnoes //server.cyborgworkshop.org “Select ProcessID,Started,State from Win32_Service where Name=\”Dhcp\”"

Note that I escaped (\) the quotes on DHCP. It’s important. Do it.

Outputs

CLASS: Win32_Service
Name|ProcessId|Started|State
Dhcp|1196|True|Running

Apr 21

I don’t usually write about specific products, but I have to drop a line about this new Atom 330 based board that I picked up from newegg. First off, it’s a dual core Atom CPU (with HT) that clocks in at 1.6ghz in 8 watts. Two SATA 2 ports and a single IDE attach the storage, 1 PCI slot, 1 DDR2 DIMM slot, onboard RTL gigabit LAN and Intel analog video with s-video out. Pretty much a 3 generation old PC. But here is the kicker, this little board runs EVERYTHING! Right now, I’m triple booting OSX (Kalyway with 0 tweaks, it just works) Mint Linux XFCE and VMWare ESXi (!). The ESXi did require me to smack in an intel based NIC, but the ICH7 chipset allows you to use the onboard sata storage as VMFS. The only real drag about this board is that it tops out at 2 gig of RAM, otherwise I would be ordering these things in bulk!

« Previous Entries Next Entries »