DEV Community

Cover image for Generate SSH key
Filimonov
Filimonov

Posted on • Updated on • Originally published at zen.yandex.ru

 

Generate SSH key

You need ssh key to connect to the server without a password.

I. Create a new ssh key

Enter the command:

ssh-keygen -t rsa -b 4096 -C "login@mail.com"
Enter fullscreen mode Exit fullscreen mode

The terminal asks you to set a password for the key and specify the location where it will be located. If you don't need it just press enter to the end.

The file will be located at:

/home/user/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode

The contents of this file are your public key.

II. Add ssh key to the server

Enter the command:

ssh-copy-id user@server.com
Enter fullscreen mode Exit fullscreen mode

Enter the password.
PROFIT.

Top comments (2)

Collapse
 
ferricoxide profile image
Thomas H Jones II

It would be a really bad idea to not password-protect your key (especially if you're logging in to an account that has sudoers capabilities).

Collapse
 
filimonov profile image
Filimonov

I agree but it is a case study. I tried to write it shortly.

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.