SSH Setup On macOS
This is just a quick documentation to setup SSH on a MacBook.
SSH is already installed on MacOS. You can confirm with ssh -V.
When you have never used SSH, you will not have a .ssh folder in your profile. When using it the first time, it should automatically be added.
You need to make a couple of adjustments now:
chmod 700 .ssh
This sets the permission, that only the owner can read/write and execute.
chmod 600 .ssh/my_private_key
This sets the permission, that only the owner can read/write.
ls -la .ssh
Check the changes you have made.
eval "$(ssh-agent -s)"
Start the agent.
ssh-add .ssh/my_private_key
Loads SSH key in to the running agent.
ssh-add -l
Confirm key is loaded.
ssh-add --apple-use-keychain ~/.ssh/my_private_key
After this command, we will be asked to enter our password for the private key. We add it to the keychain, to not need to enter the password over and over again.
We can make our lifes even simpler.
For this, I like to do this:
nano .ssh/config
To create and edit the “config” file.
Paste following in the file:
Host my_server
HostName 192.168.1.2
IdentityFile ~/.ssh/my_private_key
Now you can simply enter ssh my_server and the SSH session gets etablished.