-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testdata: Include a test for askpass during signing
Signed-off-by: Morten Linderud <morten@linderud.pw>
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Create an askpass binary | ||
env SSH_ASKPASS=./askpass-test | ||
exec go build -o askpass-test askpass.go | ||
exec ./askpass-test passphrase | ||
|
||
# ssh sign file with password - ecdsa | ||
env SSH_ASKPASS_REQUIRE=force | ||
exec ssh-tpm-agent -d --no-load &agent& | ||
exec ssh-tpm-keygen -N 12345 | ||
exec ssh-tpm-add | ||
stdout id_ecdsa.tpm | ||
exec ssh-add -l | ||
stdout ECDSA | ||
exec ssh-keygen -Y sign -n file -f .ssh/id_ecdsa.pub file_to_sign.txt | ||
stdin file_to_sign.txt | ||
exec ssh-keygen -Y check-novalidate -n file -f .ssh/id_ecdsa.pub -s file_to_sign.txt.sig | ||
exists file_to_sign.txt.sig | ||
exec ssh-add -D | ||
rm file_to_sign.txt.sig | ||
|
||
-- file_to_sign.txt -- | ||
Hello World | ||
|
||
-- go.mod -- | ||
module example.com/askpass | ||
|
||
-- askpass.go -- | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
if strings.Contains(os.Args[1], "passphrase") { | ||
fmt.Println("12345") | ||
} | ||
} |