pub struct AskpassHandler { /* private fields */ }Expand description
A temporary SSH_ASKPASS script that outputs a stored passphrase.
Create one of these before running ssh-add (or any SSH tool that may
prompt for a passphrase) and use apply_to_command
to inject the necessary environment variables.
Implementations§
Source§impl AskpassHandler
impl AskpassHandler
Sourcepub fn new(passphrase: &str) -> Result<Self>
pub fn new(passphrase: &str) -> Result<Self>
Create a new askpass handler that will output the given passphrase.
Writes a temporary executable script to disk. The script prints the passphrase to stdout and exits.
§Errors
Returns an error if the temporary script cannot be written or made executable.
Sourcepub fn script_path(&self) -> &Path
pub fn script_path(&self) -> &Path
Return the path to the temporary askpass script.
Sourcepub fn apply_to_command(&self, cmd: Expression) -> Expression
pub fn apply_to_command(&self, cmd: Expression) -> Expression
Inject the SSH_ASKPASS, SSH_ASKPASS_REQUIRE, and DISPLAY
environment variables into a duct::Expression command.
This configures the command so that any SSH tool invocation that needs a passphrase will call our temporary script instead of trying to read from the terminal.
DISPLAY is set to ":0" as a dummy value because some SSH
implementations require it to be set for SSH_ASKPASS to be used.
SSH_ASKPASS_REQUIRE=force overrides the check for whether a terminal
is available, ensuring the askpass program is always used.