Already using
ssh-copy-id
? Great! But still manually adding the same configuration info to~/.ssh/config
? No more!
This script creates an alias in ~/.ssh/config
based on your input.
$ ssh-save-id root@somehost.com
$ ssh-copy-id root@somehost.com // copies your public-key to the remote host ($ brew install ssh-copy-id)
$ ssh-save-id root@somehost.com // uses the host-part as an alias in ~/.ssh/config
$ ssh somehost.com // use the alias to connect to the remote host
Download the script directly from GitHub:
$ curl -O https://raw.githubusercontent.com/vjanssens/ssh-save-id/master/ssh-save-id
Then ensure it is executable:
$ chmod a+x ssh-save-id
Drop it in your $PATH
OR move it to a default location:
$ mv ssh-save-id /usr/local/bin/ssh-save-id
And test if it works:
$ ssh-save-id -h
Do you see the usage instructions as stated below? Great, start saving time!
Usage: ssh-save-id [-h|-n] [-p port] user@hostname
-n: dry run -- no aliasses are actually saved
-h: print this help