Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1589  / 1 Year ago, fri, december 23, 2022, 2:09:22

I've been trying to set my vps to use SSH keys for login instead of password. I've been reading tutorial after tutorial on how to set this up but I just can't set it up right.



So what I have done so far is the following



ssh-keygen -t rsa -b 4096

Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
af:3a:f2:75:5f:c2:67:c8:ad:1d:0a:ab root@localhost


Copied Public Key into authorized_keys



cp root/.ssh/id_rsa.pub /root/.ssh/authorized_keys


The issue is, how do I login via this key? Do I save the private key on notepad? Because if SSH key logs me in via ip, I don't think I can login because my ip is dynamic . Can someone help me?


More From » ssh

 Answers
4

The contents of id_rsa.pub have to be added to the file /root/.ssh/authorized_keys on the machine that you want to log into as root. On that ("target") machine, sshd also has to be configured to allow public key authentication. See sshd_config(5).



After this, you ssh as user root from some other machine to the target machine (by name or IP address, it doesn't matter). If you have protected the private key file /root/.ssh/id_rsa with a password then ssh asks you for the password so that it can read the private key.


[#30708] Saturday, December 24, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arsleyeuth

Total Points: 72
Total Questions: 121
Total Answers: 112

Location: North Korea
Member since Mon, Oct 31, 2022
2 Years ago
;