Python: Configure SSH keys
This documentation is part of the Deploy with GitHub Actions guide. You can view the complete guide here: How to deploy your Python code using GitHub Actions.
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use Python 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 Python cloud hosting solution!
SSH keys allow GitHub Actions to securely connect to your Python service for code deployment. This step is essential for protecting your Stackhero services.
On your computer, you can generate new SSH keys by running:
ssh-keygen -C "" -f /tmp/ssh_key -N ""
Add the public key
First, display the public key you have just generated:
cat /tmp/ssh_key.pub
Next, in your Stackhero dashboard, select your "production" Python service and click the "Configure" button.
Get service settings
Follow these steps:
- Under
SSH public keys, click onAdd a public key. - For
Description, enterGitHub Action. - For
Key, paste the public key you have just copied.
Add public key
Add the private key
Go to your GitHub project page, click on Settings, then Environments. Choose New environment.
Configuring GitHub environments
In the Name field, type "production" and confirm.
Setting the environment
Click on the No restriction button and select Selected branches and tags.
Setting environment restrictions
Then, click on Add deployment branch or tag rule, enter "production" in the Name pattern field, and click Add rule.
Setting environment branch
Setting environment branch
In the Environment secrets section, click Add secret.
Add secret
Now, display the private key you generated earlier:
cat /tmp/ssh_key
In the secret setup, use STACKHERO_SSH_PRIVATE_KEY as the Name and paste the private key as the Value.
Setting the SSH private key secret
Next, in the Environment variables section, click on Add variable.
Setting variables
Enter STACKHERO_ENDPOINT as the Name and paste your Python service endpoint as the Value. You will find this endpoint in your Stackhero dashboard.
Setting the endpoint variable
If you have customised your service's domain name, use the customised version instead of <XXXXXX>.stackhero-network.com.
Delete the generated keys
For security reasons, it is advisable to delete the SSH keys from your computer now, as you will not need them anymore:
rm /tmp/ssh_key /tmp/ssh_key.pub