Utility functions for manipulating ssh keys

Tomas Doran



9,024 latest version

3.9 quality score

Version information

  • 0.0.2 (latest)
  • 0.0.1
released Nov 9th 2013

Start using this module


bobtfish/sshkey_utilities — version 0.0.2 Nov 9th 2013


[Build Status

####Table of Contents

  1. Overview
  2. Reference - Functions included
  3. Limitations - OS compatibility, etc.
  4. Development - Guide for contributing to the module


Provides funcions for manipulating ssh private and public keys from strings.

If you want to work on ssh keys in files then you can use the built in file() function to read them in, or my enhanced better_file module



Takes the public key text as a parameter and returns the key fingerprint.

For example:

$public_key = file('/etc/ssh/')
$fingerprint = sshkey_fingerprint_from_public_key($public_key)


Generates and returns the public key corresponding to a given private key, the text of which should be supllied as a parameter.

The private key must not have a passphrase.

For example:

$private_key = file('/etc/ssh/host_rsa_key')
$public_key = sshkey_public_key_from_private_key($private_key)


This module should be compatible with any POSIX system which ships a 'setsid' command.

If your unix doesn't (coughApplecough) then see here:


Patches welcome! Please send pull requests or suggestions on github.