Save Servers SSH Keys, IP, Port, HostName in macOS Mountain range - Terminal & SSH Config Tips

Though discussions both here and on several forums about the fact that the new macOS Sierra, Private key sites are not kept Keychain after restarting the system.

For server administrators, who use a secure SSH connection with an authentication key, this is a little annoying. Every time they want to authenticate via SSH/Terminal, should execute the command: ssh-add -K ~ path / private_key.pem, after which in Terminal to execute the command line for connection and authentication to the managed servers. As a rule, the command is executed: ssh root @ ip_address.

A simpler solution would be to edit the ~ / .ssh / config file in which to create a kind of alias, both for the authentication key and for the user and hostname.

1. open application Terminal on macOS and execute the command:

sudo nano ~/.ssh/config

2. Add the following lines:

Host anyname
 HostName IPServer
 Port 22
 User root
 IdentityFile /Volumes/path/private_keys.pem

3. Ctrl+X then Y si Enter to save the changes in config.

For authentication via Terminal, the command line will be executed: ssh anyname. Authentication will be done automatically with the "root" user on the hostname and port indicated in the config, using the authentication key indicated in "IdentityFile".

You can add as many aliases as you want in the ~ / .ssh / config file. The condition is that at the "Host" line you have different names.

Passionate about technology, I enjoy writing on StealthSettings.com since 2006. I have a rich experience in operating systems: macOS, Windows, and Linux, as well as in programming languages and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, PrestaShop).

How to » iHowTo » iHowTo - macOS » Save Servers SSH Keys, IP, Port, HostName in macOS Mountain range - Terminal & SSH Config Tips
Leave a Comment