8. Configure SSH connection to Mac home server
Open home server SSH
In home server, Go to System Settings - General - Sharing - Remote Login - On
This allows SSH, SFTP connection. Click i button, User and IP is there.
Connect from a development machine in the same network.
Or
Enter password.
Create key files
SSH using password is okay. But in CI/CD Github Actions will connect to home server.
For that situation, I will use key file connection.
In development machine, (which is an SSH client)
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -f ~/.ssh/mac_mini_key-t is type. -b is byte. -f is file
It asks a passphase, I just entered blank.
Two files are created: mac_mini_key, mac_mini_key.pub
Configure using key in home server
In development machine, copy pub key to home server
Connect to home server using SSH, then insert pub key to authorized_keys file.
Key registration in SSH client
In development machine,
Add below.
Test the SSH connection
In development machine, connect to SSH using hostname.
Now no need to enter password.
Github Actions secrets will have this private key file.
Configure github secret
Go to Github site - Settings - Secrets and variables - Actions - Repository Secrets
Add below key-value.
MAC_HOST: 12.34.56.78
MAC_USERNAME: marcel
SSH_PORT: 22
SSH_KEY: -----BEGIN OPENSSH...
MAC_HOST should be public ip, not private ip. Github actions server is outside of my home network.
To get SSH_KEY, enter below in home server machine,
Then paste it in SSH_KEY secret.

Check the workflow file snippet
Connect to SSH and run a script.
A SSH connection that an action opens doesn't have PATH that .zshrc or .zprofile configures. So the path is added in script.
The FILENAME env should be registered in envs, otherwise the script will not replace it.
Last updated