Generate SSH Keys on Linux. SSH is a cryptographic network protocol which is used to securely connect to a host over an unsecured connection. By default, any Linux operating system supports SSH; hence using a third party client is unnecessary like in the Windows platform.
ow do I generate ssh keys under Linux / UNIX / Mac OS X and *BSD operating systems for remote login?The ssh-keygen command generates, manages and converts authentication keys for ssh client and server usage. Type the following command to generate ssh keys (open terminal and type the command):$ ssh-keygen
Generate SSH keys looks as follows:
The above command creates ~/.ssh/ directory. So if your user name is vivek, than all files are stored in /home/vivek/.ssh/ or $HOME/.ssh/ directory as follows:
Please note that the passphrase must be different from your current password and do not share keys or passphrase with anyone. Also, make sure you have correct and secure permissions on $HOME/.ssh/ directory:
You need to copy $HOME/.ssh/id_rsa.pub file to remote server so that you can login using keys instead of the password. Use any one of the following command to copy key to remote server called vpn22.nixcraft.net.in for vivek user:ssh-copy-id [email protected]
On some *nix system such as OS X ssh-copy-id command may not be installed, use the following commands (when prompted provide the password for remote user account called vivek) to install/append the public key on remote host:ssh [email protected] 'umask 077; mkdir .ssh'
cat $HOME/.ssh/id_rsa.pub ssh [email protected] 'cat >> .ssh/authorized_keys'
To login simply type:ssh [email protected]
The following command will help to remember passphraseexec ssh-agent $SHELL
ssh-add
ssh [email protected]
The following syntax specifies the 4096 of bits in the RSA key to creation (default 2048):ssh-keygen -t rsa -b 4096 -f ~/.ssh/aws.key -C 'My AWs cloud key'
Where,
Now install the ~/.ssh/aws.key, run:ssh-copy-id -i ~/.ssh/aws.key user@aws-server-ip
Test it with the ssh command:ssh -i ~/.ssh/aws.key ec2-user@aws-server-ip
See “How To Set up SSH Keys on a Linux / Unix System” for more info.
You learned how to create and generate ssh keys using the ssh-keygen command. Key generator download.
ADVERTISEMENTS