Multiple ssh key git password-free login configuration

ssh key password-free login

  1. Generate public key and private key
ssh-keygen -t rsa -C "[email protected]" -f ~/.ssh/ssh_name

2. Copy and save the public key in the ssh option of gitlab/github

  • github Settings --> SSH and GPG keys --> New SSH key
  • gitlab Edit profile --> SSH keys --> Add key

3. If you use the default ssh-key file name, generally no other settings are required, and you can use git push commands such as password-free use normally at this time.

4. If it is a customized ssh-keyfile name, you need to change ssh_configthe configuration in the file at this time

  • ~/.ssh/config 或者 /etc/ssh/ssh_configThe name of the public and private key used by the Mac system for configuration
vim /etc/ssh/ssh_config

Host *
#   ForwardAgent no
    IdentityFile ~/.ssh/id_rsa
    IdentityFile ~/.ssh/ssh_name

  • The installation directory of Win system in Git, such as c/Program Files/Git/etc/ssh/ssh_configthe name of the public and private keys used for configuration

    The repair method is the same as above

If it is to configure, for example, the ssh password-free login steps of the cloud server, the steps are similar to the above

1. First generate the key pair and put it in the .ssh directory of the machine. If you customize the file name of the ssh-key, you need to add the corresponding configuration in ssh_config. 2. It needs to be in the file in the directory of the remote
server Append the contents of the public key. This step can be done with commands . It can also be copied manually. 3. If you still can’t connect, you can try to modify the permissions of the file to/root.sshauthorized_keys
ssh-copy-id -i ~/.ssh/公钥.pub remote-host
authorized_keys-rw-r--r--
sudo chmod 644 xxx

Guess you like

Origin blog.csdn.net/mochenangel/article/details/124884296