Why I need to do this?
This is for security reason, you can find a lot of articles explain about it, like this one. There are many steps involved, for details, you may read through this article for details.
Then let’s get start!
Generate ssh key if you don’t have one yet
Open your commandline, then type
ssh-keygen
Follow the instruction to generate your ssh key.
Copy ssh key to remote machine
Once the key is generated, you need to copy the key to your remote machine which you created on Linode.
For Linux, you can just use ssh-copy-id. (Details, please refer here)
ssh-copy-id USERNAME@xxx.xxx.xxx.xxx
Replace USERNAME
to your username and xxx.xxx.xxx.xxx
to your ip, then follow the instruction and login again to make sure that you don’t need to enter password again.
Disable password authentication
If you have finished the steps above, then the next is disable to password login.
Login to your machine and type
sudo nano /etc/ssh/sshd_config
You will be requested for your user password since you are going to do this operation as adamin.
Then find
PasswordAuthentication yes
Change yes
to no
Save the change by press Ctrl+X
and press Y
Restart sshd service
sudo systemctl restart ssh
搶先發佈留言