How to create public key and private key

Generate Key Pair

Generate private / public key on server which you ned to run the java program.
For creation of private / public key pair which use below command on putty.

ssh-keygen -t rsa


ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/plusdigit/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/plusdigit/.ssh/id_rsa.
Your public key has been saved in /home/plusdigit/.ssh/

Private and public key will be available in home directory with .ssh folder.
If the .ssh folder is not available, just try with below command

ls -al

Private key will be id_rsa and public key as a

Copy public key to remote host

Use ssh-copy-id command for copy the public key on remote system which we need to connect.

ssh-copy-id -i /home/plusdigit/.ssh/id_rsa
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys’s password:
Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘'”
and check to make sure that only the key(s) you wanted were added.

Leave a Reply

Your email address will not be published. Required fields are marked *