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 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 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 ""

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 settingsGet service settings

Follow these steps:

  1. Under SSH public keys, click on Add a public key.
  2. For Description, enter GitHub Action.
  3. For Key, paste the public key you just copied.

Add public keyAdd public key

Go to your GitHub project page, click on Settings, then Environments. Choose New environment.

Configuring GitHub environmentsConfiguring GitHub environments

In the Name field, type "production" and confirm.

Setting the environmentSetting the environment

Click on the No restriction button and select Selected branches and tags.

Setting environment restrictionsSetting environment restrictions

Then, click on Add deployment branch or tag rule, enter "production" in the Name pattern field, and click Add rule.

Setting environment branchSetting environment branch Setting environment branchSetting environment branch

In the Environment secrets section, click Add secret.

Add secretAdd 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 secretSetting the SSH private key secret

Next, in the Environment variables section, click on Add variable.

Setting variablesSetting 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 variableSetting the endpoint variable

If you have customized your service's domain name, use the customized version instead of <XXXXXX>.stackhero-network.com.

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