Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:42:30+00:00 2026-06-12T10:42:30+00:00

I am use python fabric with all configuration in one .fab file. How can

  • 0

I am use python fabric with all configuration in one .fab file.
How can I put sensitive data as password to separate file and then import/load to fab main file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:42:31+00:00Added an answer on June 12, 2026 at 10:42 am

    Define a simple function within your fabfile.py to read your passwords out of a separate file. Something along the lines of:

    def new_getpass(username):
        with open("/etc/passwd", "r") as f:
            for entry in [l.split(":") for l in f.readlines()]:
                if entry[0] == username:
                    return entry
        return None
    

    This will return None in the event that the username cannot be found and the entire user’s record as a list in the event the user is found.

    Obviously my example is getting its data from /etc/passwd but you can easily adapt this basic functionality to your own file:

    credentials.dat

    database1|abcd1234
    database2|zyxw0987
    

    And then the above code modified to use this file like this, with the slight variation to return only the password (since we know the database name):

    def getpass(database):
        with open("credentials.dat", "r") as f:
            for entry in [l.split("|") for l in f.readlines()]:
                if entry[0] == username:
                    return entry[1]
        return None
    

    While not as simple as an import, it provides you flexibility to be able to use plaintext files to store your credentials in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use python 2.7. I have data in file 'a': myname1@abc.com;description1 myname2@abc.org;description2 myname3@this_is_ok.ok;description3 myname5@qwe.in;description4
My web stack is django/python + postgresql + linux + apache. I use fabric
I use Python in one of my products. I compiled the source code using:
I'm trying to use Python's getattr() to extract data out of a number of
I use python tarfile module. I have a system backup in tar.gz file. I
I'd like to use Python 2.6 on Windows to launch several separate command windows,
I use python's zipfile module to extract a .zip archive (Let's take this file
Can I use Python 2.7 modules from Python 2.6? Or do something to achieve
I'd like to use fabric as a tool to gather all server loads and
I use python 2.5, i like to replace certain variables in a txt file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.