API & Integrations
CLI utility
22min
description the command line interface (cli) provides secure access to passwords stored in the passwork password manager and enables their use in scripts and commands passwork cli operates in two main modes exec — fetches passwords from passwork, sets them as environment variables, and executes a specified command with access to those variables; api — provides direct access to the passwork api, allowing execution of any api method with json responses requirements python 3 10+ requests >= 2 31 0 python dotenv >= 1 0 0 cryptography >= 42 0 0 pbkdf2 >= 1 3 installation the package can be installed directly from github shell pip install git+ssh //git\@github com\ passwork me/passwork python git alternatively, install via https shell pip install git+https //github com/passwork me/passwork python git global options all commands support the following parameters parameter environment variable description host passwork host passwork server url token passwork token api access token refresh token passwork refresh token optional refresh token master key passwork master key master key used for decryption no ssl verify disables ssl certificate verification 1\ execution mode (exec) fetches and decrypts passwords from passwork, sets them as environment variables, and runs the specified command with access to those variables syntax shell passwork cli exec \[options] command to run or using the cmd option shell passwork cli exec \[options] cmd "command to run" password identification at least one of the following parameters must be specified for the exec command parameter description password id id of one or more passwords (comma separated) vault id id of one or more vaults (comma separated) folder id id of one or more folders (comma separated) tags tags to search passwords by (comma separated) how it works authentication connects to passwork server using provided credentials; password retrieval searches passwords by specified criteria; decryption decrypts passwords using the master key; environment preparation the main password value is set using the password's name as the variable; all custom fields are also available as environment variables execution launches the specified command in a new process with access to the environment variables capabilities multiple password support multiple passwords can be used at the same time; access to custom fields all custom fields are available as environment variables; variable naming spaces and characters are replaced by ; docker like syntax the command can be specified immediately after the cli parameters; save exit code the exit code of the executed command is returned use cases database access connect without storing passwords in config; api authentication run scripts requiring tokens; deployment scripts using credentials from different services; server admin tasks use passwords in automated scripts; ci/cd pipelines secure, password based automation examples get the password and execute the command shell # set required environment variables export passwork host="https //passwork example com" export passwork token="your token" export passwork master key="your master key" \# fetch password by id and run mysql client passwork cli exec password id "db password id" mysql u admin h localhost p $db password database name retrieve multiple passwords from a folder shell # fetch multiple passwords from a folder and run deployment passwork cli exec folder id "project folder id" /deploy sh use of different identifiers shell # use various identifiers passwork cli exec \\ \ password id "specific password id" \\ \ tags "production,database" \\ \ folder id "api credentials" \\ /complex deployment sh команды shell shell # use shell command explicitly passwork cli exec password id "server creds" cmd "ssh user\@server 'cat /var/log/app log | grep error' > local errors log" connecting to a server with a self signed certificate shell # disable ssl check passwork cli exec no ssl verify password id "test server password" ssh user\@test server local 2\ api mode (api) allows direct execution of api calls to passwork, with responses returned in json format syntax shell passwork cli api \[options] required parameters the api command requires the following parameters parameter description method http method (get, post, put, delete, patch) endpoint api path (e g , v1/vaults) params json string with parameters (optional) field specific field to extract from response how it works authentication connects to the passwork server; request preparation builds the http request with method and endpoint; request execution sends the request with auth headers; response handling receives and parses the json response; filtering (optional) extracts a specific field if field is provided; output prints result in json format examples retrieve list of vaults shell passwork cli api method get endpoint "v1/vaults" retrieve a specific password and extract only the name shell passwork cli api method get endpoint "v1/items/password id" field "name" search passwords by tags and extract names shell passwork cli api \\ \ method get \\ \ endpoint "v1/items/search" \\ \ params '{"tags" \["api","production"]}' \\ \ field "name" refresh access token shell passwork cli api \\ \ host "https //passwork example com" \\ \ token "your expired token" \\ \ refresh token "your refresh token" \\ \ method post \\ \ endpoint "v1/auth/refresh token" \\ \ field "token" use with self signed certificate shell passwork cli api no ssl verify method get endpoint "v1/user/profile" security credentials are not saved to disk; commands with passwords are not stored in shell history; passwords are only accessible within the running process; recommended use environment variables for credentials examples examples of additional scripts are located in the examples cli directory