Python: Configure SSH keys
This documentation is part of the Deploy with GitHub Actions guide. View the full guide here: How to deploy your Python code using GitHub Actions.
👋 Welcome to the Stackhero documentation!
Stackhero provides a ready-to-use Python cloud solution designed to streamline your deployment process:
- Deploy your application to production in seconds with a simple
git push.- Use your own domain name, with automatic HTTPS certificate configuration for secure connections handled for you.
- Rely on automatic backups, one-click updates, and predictable pricing, so you can focus on your code, not infrastructure management.
- Benefit from strong performance and security on a private, dedicated infrastructure. Your environment is isolated and protected.
Save time and simplify your workflow: you can have your code running with Stackhero's Python cloud hosting in just 5 minutes.
SSH keys allow GitHub Actions to securely connect to your Python service for code deployment. This step is crucial for protecting your Stackhero services.
On your computer, you can generate new SSH keys by running:
ssh-keygen -C "" -f /tmp/ssh_key -N ""
Set the public key
First, display the public key you 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 just copied.
Add public key
Set 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 customized your service's domain name, use the customized version instead of <XXXXXX>.stackhero-network.com.
Delete the generated keys
For security, it is a good idea to remove the SSH keys from your computer now, since you will not need them anymore:
rm /tmp/ssh_key /tmp/ssh_key.pub