| Title: | Password Entry Utilities for R, Git, and SSH |
|---|---|
| Description: | Cross-platform utilities for prompting the user for credentials or a passphrase, for example to authenticate with a server or read a protected key. Includes native programs for MacOS and Windows, hence no 'tcltk' is required. Password entry can be invoked in two different ways: directly from R via the askpass() function, or indirectly as password-entry back-end for 'ssh-agent' or 'git-credential' via the SSH_ASKPASS and GIT_ASKPASS environment variables. Thereby the user can be prompted for credentials or a passphrase if needed when R calls out to git or ssh. |
| Authors: | Jeroen Ooms [aut, cre] (ORCID: <https://orcid.org/0000-0002-4035-0289>) |
| Maintainer: | Jeroen Ooms <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.2.1 |
| Built: | 2026-06-05 10:29:35 UTC |
| Source: | https://github.com/r-lib/askpass |
Prompt the user for a password to authenticate or read a protected key.
By default, this function automatically uses the most appropriate method
based on the user platform and front-end. Users or IDEs can override this
and set a custom password entry function via the askpass option.
askpass(prompt = "Please enter your password: ")askpass(prompt = "Please enter your password: ")
prompt |
the string printed when prompting the user for input. |
By default askpass() returns NULL in non-interactive sessions.
(These include knitr runs and testthat tests.)
If you want to force a password prompt in non-interactive sessions,
set the rlib_interactive option to TRUE:
options(rlib_interactive = TRUE)
# Prompt user for passwd pw <- askpass("Please enter your password")# Prompt user for passwd pw <- askpass("Please enter your password")
This returns the path to the native askpass executable which can be used by git-credential or ssh-agent. Most users don't have worry about this.
ssh_askpass()ssh_askpass()
On Windows and MacOS the package automatically sets the SSH_ASKPASS and
GIT_ASKPASS variables on load (if not already set). If these are set
you should be able to run e.g. sys::exec_wait("ssh-add") and you should
be prompted for a passphrase if your key is protected.