Method one,
Sometimes you need to log in to ssh, you need to enter a password every time, it will be cumbersome. So set up a way to log in to Linux using RSA public key authentication.
First need to set /etc/ssh/sshd_config
on the server side # vim /etc/ssh/sshd_config
Modify the following two behaviors yes. In fact, in most cases, there is no need to modify it. The default is yes.
RSAAuthentication yes
PubkeyAuthentication yes
(1) If the client and server are both Linux machines, then we use the following method: (mentioned later in Section 2) How to generate a key pair using Putty under Windows)
We need to generate an RSA key pair on the client. Use the ssh-keygen command:
# ssh-keygen -t rsa
The parameter t means type, followed by the encryption type, here we are rsa.
You will then be prompted to enter the key to save the file name. Here we need to use the default id_rsa before we can log in. If the key you generated is used for other purposes, you can name it another name:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cake /.ssh/id_rsa):
You will be prompted to enter a passphrase, which we can leave blank so that we can't enter the password when we log in.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
You will then be prompted to generate the key successfully. This is your private key saved as ~/.ssh/id_rsa, your public key is ~/.ssh/id_rsa.pub
What we need to do now is to add the contents of id_rsa.pub The server-side ~/.ssh/autherized_keys file ends.
You can upload this file to the server and use the command:
# cat id_rsa.pub >> ~/.ssh/autherized_keys
Come here finished.
(2) Using Putty to generate a key pair under Windows:
There is a puttygen.exe program in Putty's installation directory. We run this program.
Then click Generate to start generating the key pair. We need to slide the mouse randomly within the specified box as prompted. This is to generate some random data based on the mouse trajectory.
After the build ends, we click Save Private Key to store the private key in a directory. Then assign the entire contents of the top text box and paste it to the end of the autherized_key on the Linux server.
We can now close this little program.
Now open Putty. In the options on the left, select Conneciton– SSH– Auth. In the Private key file for authentication, select the private key path you just saved.
At this point, Putty can also log in without a password.
Method 2
Using a Key Generated by a Linux Host
1. Generating a Key
[[email protected] .ssh]# Ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
e4:9a:47:a7:b4:8a:0b:98:07:b8: 70:de:6b:16:2c:[email protected]
2. Rename /root/.ssh/id_rsa.pub to /root/.ssh/authorized_keys
[[email protected] .ssh]#mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
3. Copy the private key id_rsa to the remote client
1) If the remote client is linux, copy to remote client /root/.ssh/
2), putty as remote client
putty does not recognize private keys copied directly from the server, you need to use puttygen.exe for format conversion
(1), open puttygen.exe --> Conversions --> Import Key
(2), select the copied private key file id_rsa
(3), Save private key-> id_rsa.ppk (save private key)
4 Open putty.exe
1), Session --> Host Name (fill in server address or domain name)
2), Connection --> SSH --> Auth (point Browse selects the newly generated id_rsa.ppk)
3), open
The following prompt appears after successful opening:
login as: root
Authenticating with Public key "imported-openssh-key"
---------------------------------- ------------------------------------------------
Of course you may encounter this error [because I have encountered it, huh, huh]:
Permissions 0755 for 'The public key file path you configured' are too open.
This is because of these files Some problems with permission settings
Execute the command: chmod 600 your file
(1) View the usage of each CPU core sudo top -d 1 After entering, press 1, the following CP
in Linux explains the output of the free command on Linux. The following is the result of the free r
First, PCI bus system architecture PCI is the abbreviation of Peripheral Component Interco
Under ubuntu bower reported EACCES: permissiondenied solution, used ower express to use bow
Linux configuration multiple IP
How does Linux extend the XFS file system?
Linuxweb directory file full script
Linuxfind removes error messages
The tool bootchart that records the Linux boot process
Linux command learning - netstat
How to enter linux single-user mode maintenance
The passwd command utility tips in Linux system summary
Delete read-ahead files to increase system speed
Windows7 does not recognize dual graphics card BUG
Windows 7 features: Ringtone Editor
How to record TV shows under Vista Media Center
Offloading for Win7 Deleting the Infrequently Used Applications
Microsoft: Windows7 currently sells more than all other versions
Clean up the Win8 system reliability history plan
Win7 can't play the dance group?
How to manually upgrade win7 to win10?
Error 1075: Dependent service does not exist, or has been marked as deleted