Monday, February 26, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  1] [ 0]  / answers: 1 / hits: 969  / 2 Years ago, sat, december 25, 2021, 4:20:34

I would like to be able to use ssh key to log into my web server via ssh and disable password authentication completely (to eliminate brute force from malicious ip addresses). So I am reading the documentation: 

Now it instructs to do the following:

mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa

Here's the problem with running ssh-keygen. I already did that in order to generate keys to connect to my github account. So my .ssh directory already looks like this:

~/.ssh$ ls -l
total 16
-rw------- 1 viggy viggy 1766 Sep 5 20:36 id_rsa
-rw-r--r-- 1 viggy viggy 403 Sep 5 20:36
-rw-r--r-- 1 viggy viggy 4422 Dec 22 11:45 known_hosts

Will running that command again overwrite the id_rsa files? Is there a better way to store both keys?

My ultimate goal here is to not overwrite my git keys, yet generate a ssh public and private key so that I can copy the public key to ~/.ssh/authorized_keys on my web server.

More From » openssh


Pass the -f option to ssh-keygen to specify a different key file. I recommend names like ~/.ssh/target.id_rsa for the key that lets you log in to target, and use the default name ~/.ssh/id_rsa (if at all) for your default key.

To make sure that SSH will always try the right key when you connect (if it doesn't find the right key, it'll prompt you for a password, or will reject the attempt if passwords are disabled), add a IdentityFile directive to ~/.ssh/config, for example:

Host git
User gitter
IdentityFile ~/.ssh/git.example.id_rsa

Host web
User webmaster
IdentityFile ~/.ssh/hosting-provider.id_rsa

[#27863] Saturday, December 25, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 169
Total Questions: 105
Total Answers: 141

Location: Sao Tome and Principe
Member since Wed, Dec 29, 2021
2 Years ago