- Open terminal.
- Enter the command below, replacing with your email:
$ ssh-keygen -t rsa -b 4096 -C "email@example.com" -f <path to key>
The path to key should be in ~/.ssh directory, with a self-explanatory filename and no spaces.
- Type a password...
- Having a password is recommended if you're using the key to log into a server;
- Don't use a password if the key is for automatic server deploys or other automated tasks;
- Save the key by pressing enter.
- Add ssh key to agent:
$ ssh-add <path to key>
- Enter password if you used one.