A Digital Life

My Notebook

View My GitHub Profile

  • About
  • 13 September 2015

    Generate SSH Key Pair

    by kerner1000

    Generate a key pair

    user@[client|server]:~$ ssh-keygen -t rsa -b 4096 -C "user@host"
    

    Install the public key

    Operating on the server

    user@server:~$ mkdir -p /home/user/.ssh/
    

    If file does not exist:

    user@server:~$ touch /home/user/.ssh/authorized_keys
    
    user@server:~$ cat [key-name]_rsa.pub >> /home/user/.ssh/authorized_keys
    

    Or operating on the client

    user@client:~$ ssh-copy-id -i [key-name]_rsa.pub user@server
    

    Move the private key [key-name]_rsa to the user client (if operating on the server).

    Activate the key

    user@client:~$ ssh-add [key-name]_rsa
    

    Log-in to the server (without pw)

    user@client:~$ ssh user@server
    
    tags: ssh