Very useful to log into a server without sharing any passwords. A common use case: deploy scripts.
$ ssh-keygen -t rsa -b 2048 -v
When asked where to put the files, just type key
. That would generate two files: ./key.pub
and ./key
.
$ ssh-copy-id -i ./key.pub user@server
In OSX you can install ssh-copy-id
with brew install ssh-copy-id
.
$ mv ./key ./key.pem
$ chmod 0400 ./key.pem
$ ssh -i ./key.pem user@server