Documentationcurrent version
Help us improve the docs by fixing typos and proposing enhancements.


Action "tools.ssh.keygen"

Generates keys for use by SSH protocol version 2.


Force the generation of a key compatible with SSH2. For example in OSX Mojave, the default export format is RFC4716.

const {$status} = await{
  bits: 2048,
  comment: '',
  target: './id_rsa',
  key_format: 'PEM'
})`Key was generated: ${$status}`)

Schema definitions

definitions =
    type: 'object'
        type: 'number'
        default: 4096
        description: '''
        Specifies the number of bits in the key to create.
        type: 'string'
        description: '''
        Comment such as a name or email.
        type: 'string'
        description: '''
        Specify a key format. The supported key formats are: `RFC4716` (RFC
        4716/SSH2 public or private key), `PKCS8` (PEM PKCS8 public key) or
        `PEM` (PEM public key).
        type: 'string'
        default: ''
        description: '''
        Key passphrase, empty string for no passphrase.
        type: 'string'
        description: '''
        Path of the generated private key.
        type: 'string'
        default: 'rsa'
        description: '''
        Type of key to create.
    required: ['target']


handler = ({config, tools: {path}}) ->
  throw Error "Invalid Option: key_format must be one of RFC4716, PKCS8 or PEM, got #{JSON.stringify config.key_format}" if config.key_format and config.key_format not in ['RFC4716', 'PKCS8', 'PEM']
  await @fs.mkdir
    target: "#{path.dirname}"
  await @execute
    $unless_exists: "#{}"
    command: [
      "-q" # Silence
      "-t #{config.type}"
      "-b #{config.bits}"
      "-m #{config.key_format}" if config.key_format
      "-C '#{config.comment.replace '\'', '\\\''}'" if config.comment
      "-N '#{config.passphrase.replace '\'', '\\\''}'"
      "-f #{}"
    ].join ' '


module.exports =
  handler: handler
    definitions: definitions
Edit on GitHub

Nikita is an open source project hosted on GitHub and developed by Adaltas.