Using OpenSSH for Linux administration

Here are some hints and tips for those who are new to using ssh/OpenSSH for Linux system administration. Most of these tips have come from my recent work with a large number of Linux servers hosted on a VMware ESXi 4.x server farm.

Password authentication VS ssh key authentication

  • If you are administering only a few systems on a closed network (i.e. accessible only locally or by a secure VPN connection), then password authentication is probably OK, but you should consider using ssh keys anyway.
  • If your network needs to allow ssh access directly from the Internet or you are administering a large number of systems, then you should definitely use ssh keys.

Ssh-agent, scripting and cron

  • ssh-agent can save you typing in the password to your ssh key every time you need it.
  • This site gives a good overview of ssh-agent and includes some code you can add to your .bash_profile script to ensure your keys get added upon login.
  • Although there are hack-ish ways to get ssh-agent and cron to work together, you are probably better off setting up special keys to use with scripts that must be called via cron. Just keep in mind that keys without passwords are a security risk.
  • If you cannot risk using keys without passwords, consider running those cron scripts locally on each system. Utilize shared file space or e-mail to collect the results.

Bash one-liners and ssh with ssh keys

  • I’ve become a fan of using bash “one-liner” scripts to keep abreast of server stats such as load averages, available patches and disk usage.
  • Keep an up-to-date list of hosts in a file called hostlist.
  • Run your one-liners while ssh-agent has your ssh keys cached.
  • Here’s a template one-liner which checks uptime on each host listed in the file hostlist:

for e in `cat hostlist`; do echo $e; ssh $e "uptime"; done

  • In the above example, you can replace uptime with just about any command which exists on the remote host.
  • You can also synchronize some of the configurations under /etc with the above by utilizing either scp or rsync instead of ssh in that one-liner.

Turn your one-liners into scripts

  • If you find yourself using the same one-liner over and over, it is time to save yourself some typing and turn it into a script.
  • I like to keep these sorts of scripts under ~/bin. I also like to add that to my $PATH and create a simlink ~/scripts.
  • Some one-liners are good candidates to be turned in to cron scripts. Just keep in mind the risks of using ssh keys without passwords, and include logic to detect conditions you want to monitor. For example, you can run /proc/loadavg through awk to isolate one of the three figures and send yourself an e-mail if that average is too high.

CIALUG August Meeting Notes

  • Meeting topic was “graphics”, but we pretty much had a free-for-all discussion.
  • Last night I complied this list of graphics-related links. We really didn’t talk about this list all that much.
  • Dave Weis from Internet Solver had swag to hand out (spiffy tees) in celebration of being recognized in the Business Record as a Best Of
  • I brought some miscellaneous electronics and books to give away.

July 2009 CIALUG Meeting Notes

CHDK – Firmware hack for Canon point-and-shoot cameras

  • TJ reviewed the installation procedure and discussed some of the extra functionality to be gained.
  • Installs to a CF card (must be under 4 GB).
  • Booting to it does not replace anything on your camera, so camera’s firmware remains un-touched (read: you won’t void your warranty).
  • CHDK Wiki

Linux-y stuff

  • It does help to connect an antenna to your internal wireless card.
  • What happens when you send /dev/null to /dev/null? How do you get it back?

Social Media

  • Origins: USENET and IRC. MUDs, MUSHes and MOOs.
  • Photo sharing sites such as SmugMug, Picasa, Flickr, Shutterbug, PhotoBucket, etc.
  • OpenID use with sites.
  • Facebook, MySpace, etc.

After-meeting at Raccoon River Brewery

June 2009 CIALUG Meeting Notes

I didn’t take any notes during the meeting itself, so these are the high points as my memory serves:

The focus of this meeting was Security, and we didn’t stray too far off that core topic.

InfraGard is a partnership between the Federal Bureau of Investigation and the private sector.

Some of the interesting security tools or concepts discussed at this meeting:

  • netcat is literally THE Swiss Army Knife of IP tools.
  • port knocking and webknocking involves sending patterns of traffic to a server to trigger it opening ports and services to your IP address.
  • MetaSploit Framework automates the exploitation of the latest vulnerabilities.

After the meeting, a large group of us walked over to Raccoon River Brewery for dinner, drinks and discussion.

May 2009 CIALUG Meeting Notes

This meeting’s theme: Programming

Eclipse IDE presented by Dan Juliano

  • http://www.eclipse.org
  • UI layer runs on top of SWT libraries, so it should be more responsive.
  • Engineered differently than most other IDEs
  • Fairly memory-intensive. Just launched, it took 135 MB of RAM on Dan’s demo system (an Intel Mac).
  • IBM has put a lot of support behind this project.
  • Primarily supports Java development, but there are versions and plugins for other languages.
  • Aptana http://www.aptana.com is an online web dev environment that fits nicely with Eclipse.
  • Good code validation plugin which will validate various languages.
  • Standard IDE stuff like syntax highlighting.
  • Has a large undo feature that remembers every change made since you started the session and can revert to any point. That causes a lot of the memory usage.

Several random discussions took place at this point in the meeting.

Hudson (https://hudson.dev.java.net/) presented by Dan Juliano

  • Billed as an “Extensible continuous integration engine”
  • Tons of plugins.
  • Dan exploring using this for automated scheduled jobs as a replacement for doing the same with cron.

Several members of the group adjourned to Hessen Haus for food and beverages.

March 2009 CIALUG Meeting

Zimbra Open Source Collaboration Suite

Presented by Rich Harms

Intro

  • Zimbra is more than just a simple mail server. It is a full collaboration suite.
  • Web browser client and offline client are extremely similar.
  • Supports IMAP and POP3 clients. Outlook, Thunderbird and the like.
  • Shared Calendars, document spaces and such not only within the company but with external users as well.
  • Powerful built-in search features.* Wiki-like document features.
  • Spamassassin and virus scanning built in.
  • Built on several other Open Source projects.
  • Zimlets scripting language for administrative and feature add-ons.
  • ZMProv utility for scripting admin tasks.
  • Import utility for pulling in Exchange data (licensed).

Installation from scratch

  • CentOS 5.2 virtual machine for the demo.
  • Download the OSE edition as a tgz file.
  • Run the included installer shell script which walks you through the install.
    • Install script is text-based, and starts out with some questions.
    • After the interview, it unpacks the RPMs, installs them and configures itself.
    • After it unpacks and installs, there are a few more questions, then completes the install.
    • At this point, you should have a basic running configuration.

Administrative Interface

  • Accessible via https://{siteurl}:7071/zimbraAdmin
  • Domains are pretty easy to set up, just a few steps configures all the services on the back end.
  • User setups are pretty easy. Password is not required, but you can’t log in with a null password!
  • Resources have their own management section.
  • Class of Service controls what features that client sees and can access.
  • Built-in IM server which uses the Jabber protocol.
  • Full control over what themes are available on the webmail interface.
  • Domains can be configured to be hosted on a specific server (clustering features).
  • Can also use the Zimbra server for LDAP authentication on your network to provide authentication for users on workstations.

Good Things

  • Lots of Zimlets, or plug-ins to add features. Some which are available are Bugzilla integration, Asterisk integration, WebEx integration, etc.
  • Good statistics gathering and reporting interface.
  • Some basic Exchange integration is built in to the Open Source version. The more advanced features require licensing, though.
  • Rich search features for building custom searches for Admin accounts, locked out accounts, inactives, etc.
  • Client can pull e-mail from multiple servers such as Gmail, Yahoo, mail-enabled PBX, etc.
  • Works with smartphones such as the Iphone (via IMAPS).
  • Two-month “try before you buy” license is available for the non-OS version.

Complaints

  • Web interface sometimes truncates HTML messages.
  • Most, but not all PCI requirements can be met within the configuration. Logging login failures is a bit wonky, so hard to bring into compliance.
  • User training can be tricky. Recommend leaving all unnecessary features disabled and only enable them as needed.
  • Non-core Zimlets require manual updating. No package management system for them.
  • Large mailboxes (10+ GB) can cause issues requiring more server-side RAM.
  • Be sure to install cron on your server! Zimbra will happily re-import logs, which it expects to be rotated by cron.
  • Backup management is missing from the OS version, but present in the licensed version.
  • Missing the Assigned Tasks feature Outlook/Exchange users are used to.
  • Exchange import wizard did not import recurring calendar appointments.

Podcast Favorites: Linux Outlaws

Even when I get a back log of podcasts and have to decide which ones to delete, every episode of this podcast stays in the queue.

Dan and Fab have a solid format wherein they cover new releases of Open Source software (mostly Linux distros), recent tech news headlines (including Microwatch), in depth Linux distro reviews and listener feedback (with Dan’s hilarious attempts at various accents from around the world).

Dan and Fab have a great rapport which makes every episode a fun listen that is also full of good content. If you want to keep on top of what’s going on with Linux and Open Source software, download a couple of episodes and give Linux Outlaws a try.

Demo FAIL, but ReciPants GO

Well, my demo of the Linux Gamers Live DVD didn’t go so well. My crappy old computer did not perform very well, so we ended up borrowing someone’s laptop to perform the demo. Wasn’t too exciting. I just brought up each game on the disk and played them for a bit. We also discussed some other Linux-friendly gaming.

After that FAIL, I needed some success. I finally got some relief with the ReciPants database issue. The problem seems to be with my method for transferring the database from the old server to the new. Here’s a brief synopsis of what I did to get it to work:

Migrated from the old server (with MySQL 3.23) to a virtual machine running CentOS 3 (also with MySQL 3.23).

On the old server:

  • Exported the database with the following command (no extra options used, my mistake was exporting with —opt and/or —add-drop-tables):

mysqldump -u root -p ReciPants > ReciPants-database.sql

On the “new” server:

  • Set up ReciPants v1.2 on the new server, per the Web site instructions — including running the SQL scripts tables-mysql.sql and ref_data.sql.
  • Once I confirmed that worked OK, restored the data from the old
    server with the following command (the -f is necessary, as there is a
    non-critical error early on that will halt the process):

mysql -u root -p -f ReciPants < ReciPants-database.sql

Again, I need to test the above method on MySQL 5.x, but I believe it will work just fine.

Working on a demo. . .

At the Central Iowa Linux User’s Group meeting this Wednesday (10/15), the theme is “Linux Gaming.” I intend to demo the Linux Gamers Live DVD on an older AMD 2 GHz box I have.

The problem with that? I need a better video card, more RAM and to download the bootable iso! The on-board SIS video sucks for gaming, the system has only 512 MB of RAM installed, and I deleted my copy of the iso file a couple of weeks ago, thinking I wouldn’t need it. . .

I managed to purchase an ATI Radeon X1550 this afternoon, so that’s one thing off the list. I’m downloading the 3+ GB iso image as I type this. The only thing left is the RAM. I went to two local computer shops today and neither had the RAM I need (either PC2100, PC2700 or PC3200). I’ve got one more local shop to check tomorrow.

Wish me luck.