Current location - Quotes Website - Collection of slogans - How to log in to a remote server using SSH
How to log in to a remote server using SSH
Default configuration

There are many SSH tools under Windows. I use putty here. If Git is installed and Putty is configured, you don't need to install Putty. The command to connect to the server using SSH is as follows:

Ssh IP address 1

Generally speaking, for security reasons, some parameters such as port number do not use default values. In this case, the command becomes like this:

Ssh username @IP address -p port number 1

If the connection is successful, you will be prompted to enter the password of the remote server. After all successful, SSH will display the prompt of the remote server, indicating that the connection is successful.

Key login

It is troublesome and not necessarily safe to enter the password every time you log in to SH. SSH can also use another login method, namely one-click login. This login method requires the client to generate a bunch of public key and private key pairs, and then add the public key to the server, so that you can log in directly next time.

First, generate the SSH key and enter the information according to the prompt. The default generation is in. Ssh folder in the user's home directory. The one with pub is the public key, which needs to be added to the server next.

ssh-keygen 1

Then add the local public key to the server, which requires another command:

Scp -P Port Number Local File Path User Name @ Remote Server Address: Remote Path 1

Then log in to the server, find the copied public key, change the public key name to authorized_keys and add it to the corresponding. Ssh folder. Then exit SSH and try logging in again. If successful, you will directly enter the remote server without entering a password.