Contents
SSH connection with authentication using public key cryptography
Creation of public and private key pairs
Create a public/private key pair for a user connecting to the Linux server using OpenSSH.
Use ssh-keygen to create key pairs.
Creation of public/private key pairs is performed with remote login user privileges。
If you do not specify the destination and file name, id_ed25519 and id_ed25519.pub will be created in /home/(user name)/.ssh/. On the way, enter the password for the key.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# su - huong [huong@Lepard~]$ ssh-keygen -t ed25519 Generating public/private ed25519 key pair. Enter file in which to save the key (/home/huong/.ssh/id_ed25519): Created directory '/home/huong/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/huong/.ssh/id_ed25519 Your public key has been saved in /home/huong/.ssh/id_ed25519.pub The key fingerprint is: SHA256:Yq9/XCRZ6jjImkPg2FvzwFaAHaIiaoZGmMUVq6uYo18 huong@Lepard The key's randomart image is: +--[ED25519 256]--+ | .o++o | |.+o.o. . | |*. .. + | |* .. . + . | |oB.o oo.So o | |= o.B.ooo . . | | .=E* .o . | |oo..+ .. o | |*o. ..... | +----[SHA256]-----+ |
1 2 3 |
$ cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys $ chmod 600 ~/.ssh/authorized_keys $ chmod 700 ~/.ssh/ |
Save the created private key id_ed25519 to an appropriate location on windows using winSCP.
Start Winscp
Host name : Server IP Address
Port number : SSH port number
User name : Server Login User
Password : Password for the same user
Click "Save"
![](https://korodes.com/wp-content/uploads/2023/10/238359d247bbdf0b4db4e98d27c25348.png)
Site name : Any name
Click "OK
![](https://korodes.com/wp-content/uploads/2023/10/65624bb89728a86938692dd030991cfc.png)
After confirming the server, click "Login".
![](https://korodes.com/wp-content/uploads/2023/10/8228849778e1040691daf83d6713e688.png)
Click "Update" when the following screen appears
![](https://korodes.com/wp-content/uploads/2023/10/9d618e966af6be865e7826b04cf3cd02.png)
Password of the logged-in user in the Password field
![](https://korodes.com/wp-content/uploads/2023/10/e4579565dbe48671e1340df0ddea36a8.png)
When connected, the right column is the server side and the left column is the PC (Windows) side.
Save the file "id_ed25519" in the .ssh directory to an appropriate location on Windows in the left column.
![](https://korodes.com/wp-content/uploads/2023/10/74bd5318ff424e3ff809852789f8097f.png)
Editing SSH Configuration File
Edit the SSH configuration file to disable password authentication.
This time, instead of being an ordinary user, su - to become root.
1 2 3 4 5 6 7 |
$ su - Password: # vi /etc/ssh/sshd_config # Line 66 : Changed to no password authentication PasswordAuthentication no # systemctl restart sshd |
How to connect with Tera Term
Start Tera Term, and select "File" menu "New connection"
![](https://korodes.com/wp-content/uploads/2023/10/eec3f2225778492398ed2413528bb3d8.png)
Host : Server IP Address
TCP port : SSH port number
If you get the following security warning Check "Replace...." and click "Continue".
![](https://korodes.com/wp-content/uploads/2023/10/865a225f055094e184c54fc07d9462a1.png)
User name : Login User Name
Password : Password specified in the creation of a public/private key pair
Under "Use RSA/DSA/ECDSA/ED25519 key to log in", set "Private key file:" to "id_ed25519" that you just saved in Windows. and click "OK".
![](https://korodes.com/wp-content/uploads/2023/10/36e0b32229ca2080bee6b319f4a194aa.png)
Creating a private key using PuTTYgen
Start Winscp and launch [Run Puttygen] from [Tools].
Select the appropriate server
![](https://korodes.com/wp-content/uploads/2023/10/65d789f82864ca1a6b9279e4d14566ec.png)
Click Load
![](https://korodes.com/wp-content/uploads/2023/10/9dead9de209300b4115a75374890bf41.png)
The [ Open File Dialog ] will open, change the file type to [ All Files (*. Change the file type to [ All Files (*. *) ] and load the private key id_ed25519 that was transferred from the Linux server.
![](https://korodes.com/wp-content/uploads/2023/10/ef793d4c2599ee120a7eb743b8c2fb60.png)
The password is the password set in "Creating a public and private key pair" above
![](https://korodes.com/wp-content/uploads/2023/10/44367b450fa3d995fbe7b91df6e3d909.png)
![](https://korodes.com/wp-content/uploads/2023/10/eea8f9ed7b5800153082df7af27e21ec.png)
Click on "Save private key"
![](https://korodes.com/wp-content/uploads/2023/10/7f2f42905c8ec947cde7e232447671ef.png)
Save the file with the extension ".ppk" in the same place as "id_ed25519" saved earlier on the Windows side under the name "id_ed25519.ppk".
![](https://korodes.com/wp-content/uploads/2023/10/5b4184805f265310989c3bac4be1f825.png)
Select the appropriate server and click "Edit"
![](https://korodes.com/wp-content/uploads/2023/10/527479fcdcb984b720cef24e9a0ebf32.png)
Click on "Advanced"
![](https://korodes.com/wp-content/uploads/2023/10/9e6a2c64bdc973a2ae963611046cb3ee.png)
Open the "Authentication" menu and specify "id_ed25519.ppk" saved in Windows for "Private key file
![](https://korodes.com/wp-content/uploads/2023/10/1140aeee6a5d76b377a0606e77f2b9b1.png)
Click "Save"
![画像に alt 属性が指定されていません。ファイル名: bfba0bf3cff4026ac8c2c493af1ed504.png](https://korodes.com/wp-content/uploads/2023/10/bfba0bf3cff4026ac8c2c493af1ed504.png)
![](https://korodes.com/wp-content/uploads/2023/10/bfba0bf3cff4026ac8c2c493af1ed504.png)
Click on "Login"
![](https://korodes.com/wp-content/uploads/2023/10/b92d5a85b22074bf9e39a89afef0462e.png)
The password is the password set in "Creating a public and private key pair" above
![](https://korodes.com/wp-content/uploads/2023/10/843d5ba941bb15a9d5cb2e178a50c376.png)
When connecting with Tera Term, use the following
Use RSA/DSA/ECDSA/..." Specify "id_ed25519.ppk" saved in windows in the "Use RSA/DSA/ECDSA/..." field.
![](https://korodes.com/wp-content/uploads/2023/10/ac69587cc45376577e3d71040862165b.png)