100 Useful Command-Line Utilities
by Oliver; 201427. ssh-keygen
On your own private computer, you can ssh into a particular server without having to type in your password. To set this up, first generate rsa ssh keys:$ mkdir -p ~/.ssh && cd ~/.ssh $ ssh-keygen -t rsa -b 4096 -f localkeyThis will create two files on your computer, a public key:
~/.ssh/localkey.pub
and a private key:
~/.ssh/localkey
You can share your public key, but do not give anyone your private key!
Suppose you want to ssh into myserver.com.
Normally, that's:
$ ssh myusername@myserver.comAdd these lines to your ~/.ssh/config file:
Host Myserver HostName myserver.com User myusername IdentityFile ~/.ssh/localkeyNow cat your public key and paste it into:
~/.ssh/authorized_keys
on the remote machine (i.e., on myserver.com).
Now on your local computer, you can ssh without a password:
$ ssh MyserverYou can also use this technique to push to github.com, without having to punch your password in each time, as described here.