Login without password
Using passwords to log in to remote Linux servers has proven to be insecure and prone to brute force attacks. In this blog, I’d like to show you how to create your own key pair and test.
Generate Key Pair
1 | ~ ❤ ssh-keygen -t rsa -b 4096 -C "corvo@X1C" |
Copy the public key to your Linux server
Please copy the file which has the pub postfix, like
/home/corvo/.ssh/id_rsa_test.pub
And you need to make sure that the content in the public key will insert into a file in the target server, and the exact user your want to login with. For example, if you want to login with
xxx
, the file should be:
/home/xxx/.ssh/authorized_keys
I’d like to use ssh and just copy the content to the target file. The file should be like this:
1 | root@xxx ~/.ssh$ cat authorized_keys |
Simple Test
- You can use
-i
to specify the private key path.
1 | ~ ❤ ssh [email protected] -i ~/.ssh/id_rsa_test |
If you encounter some problems, I’d like to recommend you to use the
ssh -vvv
to print the debug log. Here is an example:
1 | ~ ❤ ssh [email protected] -i ~/.ssh/id_rsa_test -vvv |