ssh-keygen is a standard component of the
Secure Shell
The Secure Shell Protocol (SSH Protocol) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution.
SSH was designed for ...
(SSH) protocol suite found on
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
,
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
and
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
computer systems used to establish secure shell sessions between remote computers over insecure
networks, through the use of various
cryptographic
Cryptography, or cryptology (from "hidden, secret"; and ''graphein'', "to write", or '' -logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of adversarial behavior. More gen ...
techniques. The ssh-keygen utility is used to generate, manage, and convert authentication keys.
Overview
ssh-keygen is able to generate a key using one of three different
digital signature algorithms. With the help of the ssh-keygen tool, a user can create
passphrase
A passphrase is a sequence of words or other text used to control access to a computer system, program or data. It is similar to a password in usage, but a passphrase is generally longer for added security. Passphrases are often used to control ...
keys for any of these key types. To provide for unattended operation, the passphrase can be left empty, albeit at increased risk. These keys differ from keys used by the related tool
GNU Privacy Guard
GNU Privacy Guard (GnuPG or GPG) is a free-software replacement for Symantec's cryptographic software suite PGP. The software is compliant with the now obsoleted , the IETF standards-track specification of OpenPGP. Modern versions of PGP are ...
.
OpenSSH-based client and server programs have been included in
Windows 10
Windows 10 is a major release of Microsoft's Windows NT operating system. The successor to Windows 8.1, it was Software release cycle#Release to manufacturing (RTM), released to manufacturing on July 15, 2015, and later to retail on July 2 ...
since version 1803. The SSH client and key agent are enabled and available by default and the SSH server is an optional Feature-on-Demand.
Key formats supported
Example:
ssh-keygen -t rsa
Originally, with SSH protocol
version 1 (now deprecated) only the
RSA algorithm was supported. As of 2016, RSA is still considered strong, but the recommended key length has increased over time.
The SSH protocol
version 2
Version may refer to:
Computing
* Software version, a set of numbers that identify a unique evolution of a computer program
* VERSION (CONFIG.SYS directive), a configuration directive in FreeDOS
Music
* Cover version
* Dub version
* Remix
* '' ...
additionally introduced support for the
DSA algorithm. DSA is now considered weak and was disabled in OpenSSH 7.0.
Subsequently,
OpenSSH added support for a third digital signature algorithm,
ECDSA (this key format no longer uses the previous
PEM file format for private keys, nor does it depend upon the
OpenSSL
OpenSSL is a software library for applications that provide secure communications over computer networks against eavesdropping, and identify the party at the other end. It is widely used by Internet servers, including the majority of HTTPS web ...
library to provide the cryptographic implementation).
A fourth format is supported using
Ed25519, originally developed by independent cryptography researcher
Daniel J. Bernstein.
Command syntax
The syntax of the ssh-keygen command is as follows:
ssh-keygen
ptions
Some important options of the ssh-keygen command are as follows:
Files used by the ssh-keygen utility
The ssh-keygen utility generates files for storing public and private keys.
Note : they are stored in $HOME/.ssh/ as follows:
SSH protocol version 2
*$HOME/.ssh/id_dsa: The $HOME/.ssh/id_dsa file contains the protocol version 2 DSA authentication identity of the user.
*$HOME/.ssh/id_dsa.pub: The $HOME/.ssh/id_dsa.pub file contains the DSA public key for authentication when you are using the SSH protocol version 2. A user should copy its contents in the $HOME/.ssh/authorized_keys file of the remote system where a user wants to log in using DSA authentication.
*$HOME/.ssh/id_rsa: The $HOME/.ssh/id_rsa file contains the protocol version 2 RSA authentication identity of the user. This file should not be readable by anyone but the user.
*$HOME/.ssh/id_rsa.pub: The $HOME/.ssh/id_rsa.pub file contains the protocol version 2 RSA public key for authentication. The contents of this file should be added to $HOME/.ssh/authorized_keys on all computers where a user wishes to log in using public key authentication.
SSH protocol version 1
*$HOME/.ssh/identity: The $HOME/.ssh/identity file contains the RSA private key when using the SSH protocol version 1.
*$HOME/.ssh/identity.pub: The $HOME/.ssh/identity.pub file contains the RSA public key for authentication when you are using the SSH protocol version 1. A user should copy its contents in the $HOME/.ssh/authorized_keys file of the remote system where a user wants to log in using RSA authentication.
References
External links
Generating an SSH key a guide from
GitHub
GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...
ssh-keygen manualfrom the
OpenBSD
OpenBSD is a security-focused operating system, security-focused, free software, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by fork (software development), forking NetBSD ...
project
Linux man pagefro
die.netGenerating SSH Key Pair on Linux and Macfro
ifixlinux.comBasic overview of SSH Keysfrom SSH
How to Use ssh-keygen to Generate a New SSH Key?from SSH
What is a Git SSH Key?from
Atlassian
Atlassian Corporation () is an Australia, Australian-United States, American proprietary software company that specializes in collaboration tools designed primarily for software development and project management. Domicile (law), Domiciled in ...
How to Create an SSH Key in Linux: Easy Step-by-Step Guidefrom
DigitalOcean
DigitalOcean Holdings, Inc. is an American multinational technology company and cloud service provider. The company is headquartered in New York City, New York, US, with 15 globally distributed data centers. DigitalOcean provides developers, ...
Getting Started with Oracle Cloud at Customeron
Oracle
An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination.
Descript ...
Git on the Server - Generating Your SSH Public Keyon
Git-SCM
{{Windows commands
Operating system security
Unix network-related software
Secure Shell