Skip to content

Using environment variables to connect via ssh #1433

Open

Description

@shivan-s

Description

This is not an issue but more of a feature request.

I love this tool. I am wondering if it's possible to look into the environment variables when connecting via ssh.

Say you have a .env or a .env.local with DB_URL as a set environment variable that you can ssh into.

I am happy to contribute if possible but would like some feedback on your thoughts. Thanks in advance.

Activity

  1. j-bennet commented on Oct 28, 2023

    @j-bennet
    Contributor

    @shivan-s Certainly, feel free to contribute! I believe adding python-dotenv to the requirements and calling load_dotenv would do it.

  2. shivan-s commented on Oct 29, 2023

    @shivan-s
    Author

    Great thank you!

  3. dbaty commented on May 31, 2026

    @dbaty
    Member

    I am a bit late to this (2 years and half)... but I am not sure I understand what you have in mind:

    DB_URL as a set environment variable that you can ssh into.

    Given the name, I suppose that DB_URL is not the name of the remote host you ssh into, is it? Also, is the .env file on your computer, or on the remote host (that you ssh into)? A more detailed usage example would help.

  4. shivan-s commented on May 31, 2026

    @shivan-s
    Author

    Hi @dbaty, hope you are well.

    I've been bad and haven't prioritising a contribution to this project despite my initial enthusiasm. However, I still do love this project and use it daily.

    Just for completeness and answering your question. The idea is that if you have an .env file in your project (local machine), we have a flag to parse the .env file for a variable DB_URL and we connect to this.

    .env
    DB_URL=...
    

    To be honest, I've been getting by using (using fish as an example):

    pgcli $(grep 'DB_URL' < .env | set s/DB_URI=//)

    So, I totally understand if you close this issue as totally not worth it.

  5. dbaty commented on Jun 1, 2026

    @dbaty
    Member

    Ok, got it. I was confused because of the mention of ssh, but it's actually independent. Your comment made that clearer, thanks!

    For the record, I do something very similar to what you do with grep. You're right that reading from a .env* file could be more user-friendly, obviously. We would have to look for DATABASE_URL, DB_URL, variants with URI... and maybe other common names? And hope that the format is consistent. :)

    I'll let this issue open. Contributions are most welcome! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions