This tutorial is for a window machine. The first thing you will need to do is download and install git from here. It comes with git bash which is a command line tool to run bash (command line shell) and git on windows. Bash will be using this shell to generate the keys.
Generation a ssh key
ssh-keygen -t rsa -b 4096
The file location is assumed to be in the current working directory unless you specify a fully-qualified or relative path. If you don’t specify a file name on the command line, keys are created in
~/.ssh2/ and given a default name that identifies the key type, size, and host name (for example/home/joe/.ssh2/id_rsa_2048_myhost_a). It is customery to generate your files in the directory
The flags below specifies:
- key size
- Key type
SSH is a protocol allowing secure remote login to a computer on a network using public-key cryptography. SSH client programs (
ssh into the git bash shell ) typically run for the duration of a remote login session and are configured to look for the user’s private key in a file in the user’s home directory (e.g.,
Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.
# start the ssh-agent in the background eval $(ssh-agent -s) ssh-add ~/.ssh/id_rsa
Add the public key to the server is as easy as following the next set of commands.
ssh-copy-id -i ~/.ssh/id_rsa.pub firstname.lastname@example.org
It copies the public key of your default identity (use
-i identity file) to the remote host. By default it adds the keys by appending them to the remote user’s
~/.ssh/authorized_keys (creating the file, and directory, if necessary). Of course user will have to be replaced with your actual username and host with your actual host 😄.