Ruby: Configure SSH keys
This documentation is part of the Deploy with GitHub Actions guide. View the full guide here: How to deploy your Ruby code using GitHub Actions.
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use Ruby cloud solution that provides a host of benefits, including:
- Deploy your application in seconds with a simple
git push.- Use your own domain name and benefit from the automatic configuration of HTTPS certificates for enhanced security.
- Enjoy peace of mind with automatic backups, one-click updates, and straightforward, transparent, and predictable pricing.
- Get optimal performance and robust security thanks to a private and dedicated VM.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's Ruby cloud hosting solution!
To allow GitHub Actions to deploy your code, you will need to set up SSH keys. This ensures only authorized actions can connect to your Stackhero services, keeping your deployments secure.
You can generate a new set of SSH keys on your computer using:
ssh-keygen -C "" -f /tmp/ssh_key -N ""
Set the public key
Next, retrieve the public key you just created:
cat /tmp/ssh_key.pub
In the Stackhero dashboard, select your "production" Ruby service and click the "Configure" button.
Get service settings
Then:
- Under
SSH public keys, clickAdd a public key. - For
Description, enterGitHub Action. - For
Key, paste in the public key content from your computer.
Get service settings
Set the private key
Now, head to the GitHub website and open your project.
Go to Settings > Environments, then click New environment.
Configuring GitHub environments
Name your environment "production" and save it.
Setting the environment
Click the No restriction button and choose Selected branches and tags.
Setting environment restrictions
Click Add deployment branch or tag rule, enter "production" as the pattern, and add the rule.
Setting environment branch
Setting environment branch
To store your SSH private key securely, go to Environment secrets and click Add secret.
Add secret
Retrieve your private key from your computer:
cat /tmp/ssh_key
For Name, enter STACKHERO_SSH_PRIVATE_KEY. For Value, paste your private key content.
Setting the SSH private key secret
Next, add your Ruby service's endpoint as an environment variable. Click on Add variable in Environment variables.
Setting variables
For Name, enter STACKHERO_ENDPOINT. For Value, paste the endpoint for your Ruby service, which you can find in your Stackhero dashboard.
Setting the endpoint variable
If you have set a custom domain name for your service, be sure to use that custom domain instead of <XXXXXX>.stackhero-network.com.
Delete the generated keys
Once your keys are set up in Stackhero and GitHub, you can delete them from your computer for security.
rm /tmp/ssh_key /tmp/ssh_key.pub