SSH Connection Configuration

15

SSH Key Generate

Configure ssh for password-free quick connection. First check the ~/.ssh/ folder on the local.

  1. If you have not generated id_rsa related files before, you can generate ssh keys through ssh-keygen -t rsa -b 4096 -C "[email protected]". Among them, -t rsa specifies the use of the rsa encryption algorithm, -b 4096 specifies the number of bits of the key, and -C "[email protected]" adds a note to your own email address (the note can also be other).

  2. If you are not a Windows user, you can directly use ssh-copy-id user@server to copy. If you are a Windows user, open the id_rsa.pub file in the ~/.ssh/ directory and copy the contents. Enter the server's ~/.ssh/authorized_keys file and add the contents you just copied.

(Optional) Configure SSH Client

If you want to simplify long command line instructions, for example use ssh server instead of ssh user@hostname, you can configure SSH client settings through the ~/.ssh/config file to simplify the connection command. The example is as follows:

Host server
  HostName hostname
  User user