SSH(Secure Shell) is access credential that is used in the SSH Protocol. In other words, it is a cryptographic network protocol that is used for transferring encrypted data over network. It allows you to connect to a server, or multiple servers, without having you to remember or enter your password for each system that is to login remotely from one system into another.
It always comes in key pair:
- Public key – Everyone can see it, no need to protect it. (for encryption function)
- Private key – Stays in computer, must be protected. (for decryption function)
Key pairs can be of the following types:
- User Key – If public key and private key remain with the user.
- Host Key – If public key and private key are on a remote system.
- Session key – Used when large amount of data is to be transmitted.
How SSH Works ?
It uses assymetric cipher for performing encryption and decryption. There are many encryption methods:
rsa, dsa, ed25519 etc.
General procedure is :-
- Public keys from the local computers (system) are passed to the server which is to be accessed.
- Server then identifies if the public key is registered.
- If so, the server then creates a new secret key and encrypts it with the public key which was send to it via local computer.
- This encrypted code is send to the local computer.
- This data is unlocked by the private key of the system and is send to the server.
- Server after receiving this data verifies the local computer.
- SSH creates a route and all the encrypted data are transferred through it with no security issues.
SSH is key based authentication that is not prone to brute-force attack.
It is more convenient and secure than login ids and passwords (which can be stolen in middle). There is no exposure of valid credentials, if a server has been compromised.
Generating an SSH key pair:
Open your command prompt type : ssh-keygen Press enter It will ask you for a location. Press Enter for default location. If its already there, press 'y' to overwrite. You may enter passphrase as you like, press enter.
Example of generating an SSH Key pair in latest version of Windows 10 is given below:

Generating SSH keys on Windows, Linux and Mac:
OMAC OsX and Linux : terminal (build in) OWindows :- PuTTY
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
- String Operators | Shell Script
- Basic Operators in Shell Scripting
- Shell-Metzner Sort
- How to Install and Configure Fish Shell in Ubuntu?
- How to Install Z Shell(zsh) on Linux?
- Using GitHub with SSH (Secure Shell)
- Handling missing keys in Python dictionaries
- Remove BST Keys in a given Range
- Merge two arrays keeping original keys in PHP
- Python | Remove spaces from dictionary keys
- Python | Check if given multiple keys exist in a dictionary
- Reset keys of array elements using PHP ?
- How to get a list of associative array keys in JavaScript ?
- How to iterate over the keys and values with ng-repeat in AngularJS ?
- How to get all property values of a JavaScript Object (without knowing the keys) ?
- Node.js | Buffer.keys() Method
- Windows Shortcut Keys
- Golang program that uses structs as map keys
- How to merge arrays and preserve the keys in PHP ?
- Bloom Filters - Introduction and Python Implementation
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

