跳至主要內容

How to add SSH Keys to your remote machine and disable password authentication

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.xxxto 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

Please open a new terminal to login again before you close the current session to make sure that you are still able to login without password.

分類:Hands-on

搶先發佈留言

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

由 Compete Themes 設計的 Author 佈景主題