Locating the SSH key type and key size from a public key file

One of my friends sent me an e-mail earlier this week inquiring about SSH keys. Specifically, he wanted to know how he could determine the type of key and the key-size in a public key file. All openssh implementations ship with the ssh-keygen utility, which has a “-l” option that can be used to print the type of key, the size of the key and the key’s fingerprint:

$ ssh-keygen -l -f id_dsa.pub
1024 a1:89:c8:19:a0:1a:d7:37:fa:5d:22:24:97:d7:6e:3d id_dsa.pub (DSA)

I needed to summarize all of the keys on some systems I managed a few years back, and found a new friend in ssh-keygen.

Using the ssh config file to set specify remote usernames

I periodically need to access remote systems using different userids (I didn’t have control over the account creation process, and unfortunately LDAP isn’t in use :( ). While I could use the username@host syntax to specify a userid, I find it easier to list the userids in the .ssh/config configuration file. Here is a sample configuration I use on one of my systems:

Host *.dss.prefetch.net
  ServerAliveInterval 60
  User rmatt

Host *.ext.prefetch.net
  Compression yes
  ForwardX11 yes
  IdentityFile ~/.ssh/id_dsa_ext
  User matty

The User directive can be applied to each Host configuration stanza, which allows you to specify a unique userid for each host (or group of hosts) you connect to. There are a number of cool SSH options, which are documented in the ssh_config(5) manual page. Nice!