المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : شرح انشاء مفتاح Generate private and public key in cPanel for SSH access



Rise Company
13-01-2020, 06:28
شرح انشاء مفتاح Generate private and public key in cPanel for SSH access


The common way to connect to the server via SSH is to use a username and a password. But to increase security, you can use a pair of keys(a private one and a public one) to connect to the server.
The public key will be on the server. The private key will be on your computer. When you are trying to connect, the server compares the two keys. If they are the right ones, you will be able to access it.
We will show in this post how to generate the pair of keys and connect to your server with PuTTY.
To generate and use public and private keys in cPanel:
1.Log in to cPanel
2.Scroll down to the SECURITY section -> SSH Access

https://www.rise.company/forum/images/imported/2020/01/32.png
3.Click the Manage SSH Keys button
https://www.rise.company/forum/images/imported/2020/01/33.png
4.Click the +Generate a New Key button
https://www.rise.company/forum/images/imported/2020/01/34.png
5.You are now on a page with a title Generating a Public Key. Here, choose:
-Key Name – you can leave the default value
-Key Password – enter the password for the key and confirm it
-Key Type (RSA or DSA) – let the default value
-Key Size (2048 or 4096) – let the default value
https://www.rise.company/forum/images/imported/2020/01/35.png
cPanel mentions:

RSA vs DSA: RSA and DSA are encryption algorithms used to encrypt your key. DSA is faster for Key Generation and Signing and RSA is faster for Verification.
6.Click the Generate Key button. You will see a confirmation message: Key Generation Complete! with some details:

Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
The key fingerprint is:
b7:9a:55:59:c1:a7:6a:31:5c:9a:40:50:e9:73:24:a0
7.Click the Go Back link
8.Now you need to authorize the public key. (the Authorization Status is not authorized). Click the Manage link.
https://www.rise.company/forum/images/imported/2020/01/36.png
9.You will see a message The key with the name “id_rsa” is currently “not authorized” for use when connecting to this account. Click the Authorize button. The success message is: The key “id_rsa.pub” has been authorized.
https://www.rise.company/forum/images/imported/2020/01/37.png
10.Click the Go Back link
11.Go to the Private Keys sections and click the View/Download link.
https://www.rise.company/forum/images/imported/2020/01/38.png
12.Here we will Convert the “id_rsa” key to PPK format. Enter the passphrase and click the Convert button.
https://www.rise.company/forum/images/imported/2020/01/39.png
13.You will see the key to be used in PuTTY. Click the Download key button and save the file to your computer (the filename is id_rsa.ppk)
https://www.rise.company/forum/images/imported/2020/01/40.png
14.Now start PuTTY on your computer and go to Connection->SSH->Auth. Here, browse and select the file you saved at 13. (Private key file for authentication)
https://www.rise.company/forum/images/imported/2020/01/41.png

15. Click the Open button. PuTTY will connect to the server. Enter the Passphrase when asked.
https://www.rise.company/forum/images/imported/2020/01/42.png
16.You are now connected to the server 🙂
https://www.rise.company/forum/images/imported/2020/01/43.png