arm1.ru

Creating SSH Aliases for Terminal in Mac OS X

Cheat sheet.

Everything is the same as in Linux, only on macOS there is no ssh-copy-id command. To make it available:

brew install ssh-copy-id

Further it is exactly like in Linux:

To connect to host 192.168.1.2 not via ssh root@192.168.1.2 but via ssh myhost, do the following:

Create the ~/.ssh/config file, and put this in it:

Host myhost
HostName 192.168.1.2
User root
Port 22

Next, to avoid entering the password every time, generate your keys

ssh-keygen -t rsa 

And copy the public key to the server

ssh-copy-id myhost

Update the keys:

ssh-add ~/.ssh/id_rsa
keyboard_return