In order to see your GitHub Secrets follow these steps:

  1. Create a workflow that echos all the secrets to a file.
  2. As the last step of the workflow, start a tmate session.
  3. Enter the GitHub Actions runner via SSH (the SSH address will be displayed in the action log) and view your secrets file.

Here is a complete working GitHub Action to do that:

name: Show Me the S3cr3tz
on: [push]

jobs:
  debug:
    name: Debug
    runs-on: ubuntu-latest

    steps:
    - name: Check out code
      uses: actions/checkout@v2

    - name: Set up secret file
      env:
        DEBUG_PASSWORD: ${{ secrets.DEBUG_PASSWORD }}
        DEBUG_SECRET_KEY: ${{ secrets.DEBUG_SECRET_KEY }}
      run: |
        echo $DEBUG_PASSWORD >> secrets.txt
        echo $DEBUG_SECRET_KEY >> secrets.txt

    - name: Run tmate
      uses: mxschmitt/action-tmate@v2

The reason for using tmate in order to allow SSH access, instead of just running cat secrets.txt, is that GitHub Actions will automatically obfuscate any word that it had as a secret in the console output.


That said - I agree with the commenters. You should normally avoid that. Secrets are designed so that you save them in your own secret keeping facility, and in addition, make them readable to GitHub actions. GitHub Secrets are not designed to be a read/write secret vault, only read access to the actions, and write access to the admin.

Answer from DannyB on Stack Overflow
Top answer
1 of 11
70

In order to see your GitHub Secrets follow these steps:

  1. Create a workflow that echos all the secrets to a file.
  2. As the last step of the workflow, start a tmate session.
  3. Enter the GitHub Actions runner via SSH (the SSH address will be displayed in the action log) and view your secrets file.

Here is a complete working GitHub Action to do that:

name: Show Me the S3cr3tz
on: [push]

jobs:
  debug:
    name: Debug
    runs-on: ubuntu-latest

    steps:
    - name: Check out code
      uses: actions/checkout@v2

    - name: Set up secret file
      env:
        DEBUG_PASSWORD: ${{ secrets.DEBUG_PASSWORD }}
        DEBUG_SECRET_KEY: ${{ secrets.DEBUG_SECRET_KEY }}
      run: |
        echo $DEBUG_PASSWORD >> secrets.txt
        echo $DEBUG_SECRET_KEY >> secrets.txt

    - name: Run tmate
      uses: mxschmitt/action-tmate@v2

The reason for using tmate in order to allow SSH access, instead of just running cat secrets.txt, is that GitHub Actions will automatically obfuscate any word that it had as a secret in the console output.


That said - I agree with the commenters. You should normally avoid that. Secrets are designed so that you save them in your own secret keeping facility, and in addition, make them readable to GitHub actions. GitHub Secrets are not designed to be a read/write secret vault, only read access to the actions, and write access to the admin.

2 of 11
68

The simplest approach would be:

name: Show Me the S3cr3tz
on: [push]

jobs:
  debug:
    name: Debug
    runs-on: ubuntu-latest

    steps:
    - name: Check out code
      uses: actions/checkout@v2

    - name: Set up secret file
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        ...
        ...
      run: |
        echo ${{secrets.AWS_ACCESS_KEY_ID}} | sed 's/./& /g'
        ...
        ...

Run this action in GitHub and check its console. It displays secret key with space between each character.

Discussions

Is there a way to display Github secrets value (not name) in Github CLI
I need the value of the secret returned not only the name. Is there a way to do that? I read through this issue #441 but seems like there isn't. More on github.com
🌐 github.com
2
3
April 12, 2021
How can you retrieve (read) GitHub secrets without invoking CI? - DevOps Stack Exchange
A follow up to this question How can I easily leak secrets with GitHub Actions? ... It's not currently possible to view the value of the secret without leaking the secret, which is easy enough. More on devops.stackexchange.com
🌐 devops.stackexchange.com
How can I easily leak secrets and read the value with GitHub Actions? - DevOps Stack Exchange
GitHub actions seems to block out both the secret, and the base64 dump of the secret. Is there any easy way to dump all of secrets, or a list of secrets, from GitHub Actions? I need to be able to read (view) the value of one? More on devops.stackexchange.com
🌐 devops.stackexchange.com
February 7, 2024
How to Monitor GitHub for Secrets
secret-bridge looks for secrets in the CI pipeline, but did anyone write a pre-commit hook which could scan for them earlier? More on reddit.com
🌐 r/netsec
26
201
September 25, 2019
🌐
Reddit
reddit.com › r/github › can you view / retrieve a github secret?
r/github on Reddit: Can you view / retrieve a GitHub secret?
October 7, 2022 -

I know you can store secrets in repos as well as for organisations.

I don't understand if those secrets are only for GitHub "actions", various kind of building and deploying automations, or if you could use a GitHub secret in the actual code, like just an api key for example.

I am just looking for a convenient way to store api passwords so I don't constantly have to track them down when I am on a new machine, so I thought GitHub secrets could be that, but so far I haven't figured out how to view/retrieve the secrets that I've saved.

If that's not possible I'll just use a command line secrets manager.

Thanks

🌐
GitHub
docs.github.com › en › actions › concepts › security › secrets
Secrets - GitHub Docs
Unlike a personal access token, a GitHub App is not tied to a user, so the workflow will continue to work even if the user who installed the app leaves your organization. For more information, see Making authenticated API requests with a GitHub App in a GitHub Actions workflow. GitHub Actions automatically redacts the contents of all GitHub secrets that are printed to workflow logs.
🌐
GitHub
docs.github.com › actions › security-guides › using-secrets-in-github-actions
Using secrets in GitHub Actions - GitHub Docs
On GitHub, navigate to the main page of the repository. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
🌐
AWS
docs.aws.amazon.com › aws secrets manager › user guide › get secrets from aws secrets manager › use aws secrets manager secrets in github jobs
Use AWS Secrets Manager secrets in GitHub jobs - AWS Secrets Manager
To use a secret in a GitHub job, you can use a GitHub action to retrieve secrets from AWS Secrets Manager and add them as masked Environment variables
Find elsewhere
🌐
Stack Exchange
devops.stackexchange.com › questions › 18896 › how-can-you-retrieve-read-github-secrets-without-invoking-ci
How can you retrieve (read) GitHub secrets without invoking CI? - DevOps Stack Exchange
env: # Or as an environment variable super_secret: ${{ secrets.SuperSecret }} And then the runner can do anything with them. But it seems weird if they're that easy to get to a runner, that it's impossible to get them out without a runner. You can set them in the back of GitHub, or with gh the GitHub CLI tool.
🌐
GitHub
docs.github.com › en › codespaces › managing-codespaces-for-your-organization › managing-development-environment-secrets-for-your-repository-or-organization
Managing development environment secrets for your repository or organization - GitHub Docs
If you cannot see the "Settings" tab, select the dropdown menu, then click Settings. In the "Security" section of the sidebar, select Secrets and variables, then click Codespaces. Optionally, to view ...
🌐
Stepsecurity
stepsecurity.io › blog › github-actions-secrets-management-best-practices
8 GitHub Actions Secrets Management Best Practices to Follow - StepSecurity
To access repository secrets in GitHub Actions, follow these steps: Visit the repository settings page. Explore secrets directly on the repository settings page. View the GitHub Action secrets and their metadata individually for each repository.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › GitHub-Actions-Secrets-Example-Token-Tutorial
How to use GitHub Actions secrets to hide your tokens and passwords example
That’s where the GitHub Actions secret comes in. It provides a secure vault to store your confidential information, and a simple mechanism to access those secret tokens in your GitHub Actions scripts.
🌐
GitHub
github.com › gitleaks › gitleaks
GitHub - gitleaks/gitleaks: Find secrets with Gitleaks 🔑
Gitleaks scans code, past or present, for secrets Usage: gitleaks [command] Available Commands: completion Generate the autocompletion script for the specified shell dir scan directories or files for secrets git scan git repositories for secrets help Help about any command stdin detect secrets from stdin version display gitleaks version Flags: -b, --baseline-path string path to baseline with issues that can be ignored -c, --config string config file path order of precedence: 1.
Starred by 26K users
Forked by 2K users
Languages   Go 82.9% | Go Template 16.5%
🌐
DEV Community
dev.to › pwd9000 › best-practices-for-using-github-secrets-part-1-596f
Best Practices for Using GitHub Secrets - Part 1 - DEV Community
July 18, 2024 - This article is Part 1 of a 2-Part series where we'll explore the best practices for managing sensitive information in your GitHub workflows by using GitHub Secrets using the GitHub Website UI and giving a general overview and feel for GitHub Secrets and why you would want to use them.
🌐
OnboardBase
onboardbase.com › blog › github-secrets
Github Secrets: A Complete Guide
November 10, 2022 - Secrets can also be environment configuration variables: database credentials (a database URL), API keys, token signatures… Secrets are sensitive, meaning they need security systems to protect them from being displayed to a third-party. This is where Github Secrets come in.
🌐
DEV Community
dev.to › n3wt0n › how-secrets-work-in-github-and-how-to-manage-them-p4o
How Secrets Work in GitHub and How to Manage Them - DEV Community
April 29, 2021 - Secrets at Organization Level, at Repository Level, and inside GitHub Actions Environments. The organization secrets allow you to share secrets to different repositories without the need of duplicating them. They can also be scoped to specific repositories or used in all of them.
🌐
CloudAppie
cloudappie.nl › home › posts › extract a stored github secret
Extract a stored Github secret - CloudAppie
August 20, 2024 - To convert it back to a readable string you can run echo 'myoutput' | xxd -ps -r where myoutput is the hex string you copied from the output. With that you get your secret back in a readable format.
🌐
Stack Exchange
devops.stackexchange.com › questions › 18901 › how-can-i-easily-leak-secrets-and-read-the-value-with-github-actions
How can I easily leak secrets and read the value with GitHub Actions? - DevOps Stack Exchange
February 7, 2024 - Use ${{ toJSON(secrets) }} to get all of them, space every character (fold -w1 | tr '\n' ' '), and reconstruct in Node: const spacedDump = 's p a c e d j s o n ...'; const json = spacedDump.split('').filter((_, i) => i % 2 === 0).join(''); ...
🌐
GitHub
docs.github.com › en › codespaces › managing-your-codespaces › managing-your-account-specific-secrets-for-github-codespaces
Managing your account-specific secrets for GitHub Codespaces - GitHub Docs
Under "Value", type the value of your secret. Select the "Repository access" drop-down menu, then click a repository you want to have access to the secret.
🌐
Octopus Deploy
octopus.com › blog › githubactions-secrets
Secrets In GitHub Actions | Octopus blog
March 1, 2022 - As part of our series about Continuous Integration and build servers, learn how to add secrets in GitHub to use with GitHub Actions, plus how to call them in workflows.