Automating SSH and FTP

Automating SSH Login

SSH is generally happy accepting a hash key instead of username and password, provided you can generate your keys, and get your public key placed on the destination host. What’s ironic here is that doing things the “simple” way in Windows, in a GUI, is actually kind of elaborate, while doing it the “hard” way from the command line in Linux or Unix is pretty darn easy.

If you’re stuck on the Windows side, Leo Notenboom (“Ask Leo!”) has a nice guide to generating your keys using various GUI tools at
http://ask-leo.com/how_do_i_create_and_use_public_keys_with_ssh.html.

If you are working in Linux you can directly specify RSA or DSA keys as part of your keygen command. A truly fine example using DSA by Vivek Gite is at
http://www.cyberciti.biz/faq/ssh-password-less-login-with-dsa-publickey-authentication/

Automating FTP Transfers

And Leo has a more advanced how-to at
http://ask-leo.com/how_can_i_automate_an_sftp_transfer_between_two_servers.html.

Notice in all of this that Leo suggests using no passphrase, while Vivek shows a more sophisticated solution.

CAVEAT: see what actually works on your target system!

HP-UX Printer Management

HP-UX Printer Management

First, a warning: if you’ve been looking at the Linux printer information elsewhere on this site, stop (unless you’re interested in Linux). Here’s why:

HP-UX is a System V Unix. Thus it uses lp rather than lpr as its print facility (unlike Linux, for instance.) See this HP IT Resource Center thread for more on this subject.

Administrators can consult The HP-UX System Administrator’s Guide for a thorough discussion, “Administering the LP Spooler.”
http://docstore.mik.ua/manuals/hp-ux/en/5992-4616/ch04s01.html

Geeks will like the Freelab.net AIX/HP-UX Interoperability Guide for a deep technical discussion of print operations under HP-UX:
http://www.freelab.net/unix/hp-ux/chap08_print.html.

Users seeking simple answers should check below. If you’re a user, rather than a sysadmin, what printer management you do will likely be entirely from the command line.

Task Command Examples/Comments
Print to your default printer lp document

What happens:
the shell returns a printer name and a job number:

printer1-4523

Print to another printer lp -dprinter_name document There must be no space between the -d (destination) and the printer name.
List your print jobs /usr/bin/lpstat Use this to list your print jobs and their request ID, for instance to cancel one.
Cancel a print job /usr/bin/cancel job_number The print job number looks like:
printer1-4523
Cancel all print jobs for your user on a specific printer /usr/bin/cancel -a printer_name A user can only cancel their own jobs, unless they’re superuser.
Determine lp spooler status /usr/bin/lpstat -r

What happens:
the shell returns the spooler status:

spooler is stopped

Display lp spooler activity statistics lpana Only useful to sysadmins
Alter a print request lpalt See the man page for details.
Set a default printer setenv PRINTERDEST=”printer_name You should set this in your profile files.
Allow print requests to be submitted to the request directory of a printer /usr/lib/accept printer_name This “turns on” the print queue for a single printer.
Refuse to allow print requests to be submitted to the request directory of a printer /usr/lib/reject printer_name
Enable a printer to actually print /usr/bin/enable printer_name This enables literal printing on a single printer.
Disable a printer from printing /usr/bin/disable printer_name
Start the lp spooler (the scheduler) /usr/lib/lpsched This starts actual spooling, i.e. job scheduling and processing.
Stop the lp spooler (shut it down) /usr/lib/lpshut
Printer Directories
Printer Descriptions Directory /etc/lp/*
Printer Spool Directories /var/spool/lp/*

HP-UX

HP-UX

Hewlett-Packard’s 64-bit Unix is everywhere in medical environments. If you’ve had an MRI, an MEG or a CAT Scan, it’s likely your images were managed and viewed on an HP-UX workstation.

HP-UX is a System V (as opposed to a BSD) Unix. Mac’s OS X, on the other hand, is a BSD derivative, while you can think of Linux as BSD-like in many of its functions, such as printing. The current version of the OS is 11i (or 11.11), which comes in various flavors such as the Critical Operating Environment version used in medical record storage. Older version 10 workstations are still around, sometimes for application compatibility.

Generally, I’ll keep HP-UX-specific materials here, while most other general Linux and generic Unix issues will live under the GNU/Linux heading.

Feel welcome to add to this information by commenting below.