Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

preface

This textbook is suitable for GitLab and GitHub.

I Password-free SSH connection

  1. Create rsa: ssh-keygen -t rsa -b 4096 -c “[email protected]

  2. SSH touch config: ➜

  3. Run pbcopy or ssh-copy-id to copy the public key to the corresponding remote server

➜. SSH pbcopy < ~/. SSH /qctmac_id_rsa.pub

Run the ssh-copy-id command to report data

Ssh-copy-id: never leak your private key! Just copy the public key (*.pub file) to the remote server;

‘$ssh-copy-id -i ~/. SSH /id_rsa_Theos125 [email protected]

‘(IP+ default port) Ssh-copy-id will find the public key if the private key is specified.

If the configuration is on the company Mac, set the password and remove xx_id_rsa/xx_id_rsa.pub in the ~ /. SSH/directory when replacing the Mac.

Kunnan.blog.csdn.net/article/det…

1.1 create rsa

ssh-keygen -t rsa -b 4096 -C "[email protected]"

1.2 Configuring SSH Config

Syntax of the config file

Host alias HostName: is the Host name of the target Host, which is usually followed by the address name of SSH. Port: indicates the specified Port number. User: specifies the login User name. IdentifyFile: specifies the private key address.Copy the code
# Private 192.168.2.125
Host iphone
HostName  192.168.2.125
User root 
IdentityFile ~/.ssh/id_rsa_Theos125

# Private github
Host github.com
HostName  github.com
User git
IdentityFile ~/.ssh/id_rsa


Host codechina.csdn.net
HostName  codechina.csdn.net
User git
IdentityFile ~/.ssh/qctmac_id_rsa

Copy the code

1.3 Testing the Connection

➜  csdn ssh -T [email protected]       
Enter passphrase for key '/Users/mac/.ssh/qctmac_id_rsa': 
Welcome to GitLab, @u011018979!


Copy the code

Connect the iPhone

$SSH iPhone [email protected]'s password: iPhone:~ root#Copy the code

1.4 Example: Configuring GitHub SSH Keys

Enter ls -al ~/.ssh to see if existing SSH keys are present:

If you don’t have an existing public and private key pair, or don’t wish to use any that are available to connect to GitHub, then generate a new SSH key.

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Add the corresponding public key to the corresponding remote server. SSH pbcopy < ~/. SSH /qctmac_id_rsa.pub

Git config –global –edit

Modify author: git commit –amend –reset-author

The effect

II see also

Use the SSH Config configuration file to manage SSH connections

For more, check out # Applets: iOS Reverse, which presents valuable information only for you, focusing on the mobile technology research field.