Generate SSH Key Pair

less than 1 minute read

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] >> /home/user/.ssh/authorized_keys

Or operating on the client

user@client:~$ ssh-copy-id -i [key-name] 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


Categories: ,


Leave a Comment