public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* git send-email SMTP password command
@ 2024-06-16 22:49 Jeremy Baxter
  2024-06-17  0:22 ` brian m. carlson
  0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Baxter @ 2024-06-16 22:49 UTC (permalink / raw)
  To: git

Hi list, I was wondering if it's possible to configure send-email's
default SMTP client to execute a shell command and capture its output to
get the SMTP password rather than prompting the user on the terminal.

Would anyone know if this is possible without setting
sendemail.sendmailCmd?

Thanks,

Jeremy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git send-email SMTP password command
  2024-06-16 22:49 git send-email SMTP password command Jeremy Baxter
@ 2024-06-17  0:22 ` brian m. carlson
  2024-06-24  6:01   ` Jeremy Baxter
  0 siblings, 1 reply; 3+ messages in thread
From: brian m. carlson @ 2024-06-17  0:22 UTC (permalink / raw)
  To: Jeremy Baxter; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]

On 2024-06-16 at 22:49:55, Jeremy Baxter wrote:
> Hi list, I was wondering if it's possible to configure send-email's
> default SMTP client to execute a shell command and capture its output to
> get the SMTP password rather than prompting the user on the terminal.
> 
> Would anyone know if this is possible without setting
> sendemail.sendmailCmd?

You can use a credential helper, and that can be a shell command.  For
example, you can do this:

  git -c credential.helper= \
      -c credential.helper='!f(){ echo username="$USER"; echo password="$PASS";};f' send-email ...

This resets the list of credential helpers (with the empty value) to
remove any you may have already set, and then uses that shell script to
read the credentials from the environment.  The documentation on the
protocol is in git-credentials(1) and gitcredentials(7).

You can also use your regular credential helper to store the
credentials, in which case you need not set any -c options at all.

Note that, in general, this only works for SASL authentication that uses
usernames and passwords (e.g., PLAIN, SCRAM-SHA-256, etc.), and not
things like GSSAPI (Kerberos), but you also don't need a credential
helper for GSSAPI.
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git send-email SMTP password command
  2024-06-17  0:22 ` brian m. carlson
@ 2024-06-24  6:01   ` Jeremy Baxter
  0 siblings, 0 replies; 3+ messages in thread
From: Jeremy Baxter @ 2024-06-24  6:01 UTC (permalink / raw)
  To: brian m. carlson; +Cc: git

"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> You can use a credential helper, and that can be a shell command.  For
> example, you can do this:
>
>   git -c credential.helper= \
>       -c credential.helper='!f(){ echo username="$USER"; echo password="$PASS";};f' send-email ...
>
> This resets the list of credential helpers (with the empty value) to
> remove any you may have already set, and then uses that shell script to
> read the credentials from the environment.  The documentation on the
> protocol is in git-credentials(1) and gitcredentials(7).
>
> You can also use your regular credential helper to store the
> credentials, in which case you need not set any -c options at all.

Excellent, that's working for me now. Thanks a lot!

Jeremy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-24  6:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-16 22:49 git send-email SMTP password command Jeremy Baxter
2024-06-17  0:22 ` brian m. carlson
2024-06-24  6:01   ` Jeremy Baxter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox