ssh keygen ssh add

ssh kegen

Posted by Yuan on August 30, 2021

ssh-keygen

ssh-keygen pairs:

  1. Generate key pairs The algorithm is selected using the -t option and key size using the -b option. The following commands illustrate:
    1
    2
    3
    4
    5
    
    ssh-keygen -t rsa -b 4096 
    ssh-keygen -t dsa 
    ssh-keygen -t ecdsa -b 521 
    ssh-keygen -t ed25519
    ssh-keygen -f ~/tatu-key-ecdsa -t ecdsa -b 521
    
  2. Copy the pubkey to the server
    1
    
    ssh-copy-id -i ~/.ssh/tatu-key-ecdsa user@host
    

    Once the public key has been configured on the server, the server will allow any connecting user that has the private key to log in.

  3. Add private key to ssh agent

    Firstly, run ssh-agent:

    1
    
     eval `ssh-agent`
    

    Then, add private key:(You may need to change privatekey into a 400 access code)

    1
    
     ssh-add ~/.ssh/privatekey
    

    Finally, Test:

    1
    
     ssh -vT git@github.com