Save Servers SSH Keys, IP, Port, HostName in macOS Sierra – Terminal & SSH Config Tips

There was also talked here, and on many forums about the fact that the new Sierra macOS, private keys are no longer kept in Keychain After restarting the system.

For server administrators, which use a secure SSH connection with authentication Key, this is a little annoying. Each time they want to authenticate via SSH/terminal, you should execute the order: ssh-add -K ~path/private_key.pem, then in the terminal to execute the order line for connecting and authentication to the administered servers. The order is usually executed: ssh root@ip_address.

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

1. We open the terminal application on macos and execute the command:

sudo nano ~/.ssh/config

2. We add the following lines:

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

3. Ctrl+X , then Y and Enter To save the changes in config.

For authentication via terminal, the order line will be executed: ssh anyname. Authentication will automatically be done with the user “root” On the hostname and port indicated in config, using the authentication Key indicated at “IdentityFile”.

In the file ~/.SSH/config can be added any alias you want. The condition is like the line “Host” To have different names.

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. Save Servers SSH Keys, IP, Port, HostName in macOS Sierra – Terminal & SSH Config Tips
Leave a Comment