How to set up SSH keys

To use SSH you will need the keys. To generate them run the command:

ssh-keygen

It will prompt you for a password or just press <ENTER> to use an empty one.

Two keys have been generated under hidden directory /home/your_username/.ssh
  • id_rsa (private)
  • id_rsa.pub (public)

The last and very important step is to restric access to your keys for the others. Run the commands:

chmod 600 id_rsa
chmod 600 id_rsa.pub

That's all for initial setup. Done!

To log in using your keys use the command:
ssh username@address

If you want to bind some address/port use the command:
ssh -L port:host:hostport username@address

for example: ssh -L 8888:localhost:8888 username@address

No comments:

Post a Comment