In my last post I showed a good example for using expect in a script. Here is another good example I use for updating local user passwords across a group of servers without using ssh keys. This assumes the user you are resetting can ssh to the host and the old password is the same on all hosts.
Author Archives: jro
Remote Server Shutdown
One of my recent projects was to initiate a server-wide shutdown should our UPS ever run low. I currently have Zenoss monitoring the health status of the UPS, including the remaining charge on the battery. Using Zenoss thresholds, I can make a script execute if the battery ever runs low.
Our Zenoss deployment currently runs on CentOS, so I put down a method to shut down each type of host from a linux platform. After much researching and testing, this is what I came up with (and am currently using in my shutdown script).
For Windows:
net rpc SHUTDOWN -C "Automated shutdown" -f -I "$server" -W $domain -U $username%$password |
I replaced my arguments with some that would be more readable. User and password are separated with %.
For Linux:
CMD="ssh -l $username $server shutdown -h now" expect -c " match_max 100000 spawn $CMD expect { \"Are you sure you want to continue connecting (yes/no)?\" { send \"yes\r\" exp_continue } \"password:\" { send \"$password\r\" expect -re \"$username*\" } } " |
I wanted to shutdown linux servers without using keys but had to overcome the “do you want to connect” prompt. In order to do that I had to use exact which can be installed with “yum install exact”
By turning these into functions and passing arguments, you can make a shutdown script in a couple of minutes.
VMware – Windows AMD PCNet Family Adapater Issue
Since we have ESX, I usually don’t get to spend much time playing around with VMware-Server. Interested to see the new interface in VMware-Server 2, I installed it on one of my CentOS servers.
The installation was a breeze with the rpm package and running the configuration script was pretty flawless. So I logged in through the Remote Management Console (https/port 8333), and created a fresh host. After copying over a Win2k3 iso, mounted the image and began the installation.
(On a side note I was doing this remotely, and found out that in order to use the Remote Console Client, I needed to allow ports 8333 and 902 through the firewall)
The initial Windows installation zipped right through, however, when I went to configure the network adapter none was listed. So I took a look at the Device Manager and BAM!
This device cannot start. (Code 10)
Having never come across this on VMware/Windows installation, I decided to reinstall my Windows host. Same thing.. So let’s install the driver.. that we need to download.. with no network card..
Lucky for us we have VMware! Downloaded the latest PCNet Family drivers for Windows 2003, tossed them in an .iso image, and mounted it to the Virtual CD-Rom for the host. Once I extracted/updated the driver, everything was running smooth again.
Download the .iso image here: AMD Driver v4
MD5: 78159679b644e64c0ca5618bc4de1995
Auto Logon with Windows XP
Sometimes I need to remind myself where this is located. This is primarily useful when you have shared domain workstations that need to logon automatically. Be sure to lock this workstation down!
This article describes how to configure Microsoft Windows XP to automate the logon process by storing your password and other pertinent information in the registry database. This feature permits other users to start your computer and to use the account that you establish to automatically log on.
Important If you turn on autologon, using Windows XP becomes more convenient. However, using this feature can pose a security risk.
Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
Linux Kernel Caching in Action
WDS Image Creation
As a continuation of my previous WDS post located here, these are the steps I follow for creating my WDS images.
- Install OS, drivers, service packs, software, updates, and everything else to master system.
- Copy Windows installation media to local drive: xcopy /H /E D:\* C:\windows\options\cabs\
- Copy deploy.cab from recent installation media, extract to sysprep folder located on the administrator’s desktop.
- From a Windows command prompt, browse to sysprep folder and run: sysprep.exe -mini -reseal (with optional flags)
- Wait for system to shutdown.. start system back up, ensure PXE or network boot is enabled.
- Boot from PXE/WDS, select Windows PE from options menu.
- At Windows PE command prompt, run: wdscapture
- Follow Windows Image Capture wizard.
RDPDD.dll Failed to Load
After installing .NET 3.0 on one of my test servers, I could no longer connect over RDP. From the client, the connection would just terminate with no errors. After looking at the Windows Event Log on the server, I found:
Event ID: 26
Application popup: : \SystemRoot\System32\RDPDD.dll failed to load
After looking around, this appears to be an issue with the installed nVidia driver, though ATI users have experienced this as well. Adding the following registry value and rebooting, I was able to RDP again.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management] "SessionImageSize"=dword:00000020 |
Hyperterm Replacement for Vista
I reinstalled Vista today and misplaced my Hilgraeve HyperTerminal installer, which was publicly available for download until recently. My alternate client has always been Tera Term, which is very effective, and lightweight.
Software
Here is a list of some random software I use for the majority of things I deal with:
Zenoss – Open Source Network Monitoring, takes nagios and cacti to another level. Very customizable, but takes a while to become familiar with the system. The more I play with Zenoss, I constantly come across new features and advanced functions.
Monitoring Terminal Services sessions:
Monitoring SQL locks:
Monitoring Apache:
Monitoring MySQL:
Dekiwiki – Open source WIKI, with very good media integration and built-in support for Active Directory. I prefer it over MediaWIKI.
Jing – Free desktop screen capture utility, also creates flash videos on the fly. Has its own file sharing service screencast.com for sharing your screenshots/videos. Great for making tutorials.
Linksys SRW2048 Console Cable
For our access layers we primarily use Linksys/Cisco SRW2048 managed switches. They run around $800 bucks and aside from being very reliable, have the features we need (Link Aggregation, VLAN, GB, miniGBIC). We had an issue last week where an unknown staff member (I have an idea who), created a loop along our access layer, causing our core switches (Procurve 2848 series) to block the uplink port dropping a good portion of the network. Thus, I decided to disable all inactive switch ports to prevent random IT staff from plugging stuff in.
While doing this I came across a switch that had not been configured for IP management, so I needed to console in to configure it. After trying 10 different serial cables and 100 different terminal settings, I found out that the Linksys console cable (normally included with new switches) appears to be a straight-through cable of sorts:
1 <-> 1
2 <-> 2
3 <-> 3
4 <-> 4
5 <-> 5
6 <-> 6
7 <-> 7
8 <-> 8
So I called Linksys sales, which informed me they do not sell said cable and could not send me another for free. After hanging up I contemplated a way of building my own version and looking to see what parts I had, found 2 RJ45 to DB9 adapters. Cutting off a 5′ chunk of Cat5 and wiring it straight through, I made my own pin to pin serial cable for the Linksys SRW2048.
If anyone is interested, the terminal settings are as followed:
Bits per second: 38400
Data bits: 8
Parity: None
Stop Bits: 1
Flow Control: None