Bypass PIN entry

Is there a way to pass the user PIN of a smartcard in a gpg-agent batch file or script?

I am using a nitrokey pro as a private key store for an unattended SFTP system.
It simply runs a WinSCP script to pickup and send files via SFTP.

Before the script runs I launch I run a batch file to invoke the gpg-agent:
gpg-connect-agent.exe" /bye

WinSCP is then able to use the private key on the smartcard. However, the first time I connect the pinentry program appears and requires me to enter the user PIN.

Is there a way to pass this PIN and unlock the nitrokey when gpg-agent launches?

I haven’t done this yet. Since it’s a very GPG-related question you may get a faster and better response by asking at:

Please share your results here.

I was given the solution:

Requires GPG2.1.
I was using gpg4win, which of course does not include v2.1. I needed to download the windows version from

I had some difficulty with the syntax of a windows batch file but eventually succeeded with

gpg-connect-agent.exe --run <FILE>

Where contained:

OPTION pinentry-mode=loopback
/definqfile PASSPHRASE <PIN>

where is the one in the output of ‘gpg --card-status’ and was a file containing the PIN.

1 Like

Thanks a lot.