Skip to content

Commit f76fca1

Browse files
committed
Merge remote-tracking branch 'origin/pull/125'
* origin/pull/125: ssh-tpm-agent: add `--confirm-loaded` flag
2 parents 3854ff2 + b49c37f commit f76fca1

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

agent/agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func (a *Agent) Unlock(passphrase []byte) error {
457457
return ErrOperationUnsupported
458458
}
459459

460-
func LoadKeys(keyDir string) ([]key.SSHTPMKeys, error) {
460+
func LoadKeys(keyDir string, confirm bool) ([]key.SSHTPMKeys, error) {
461461
keyDir, err := filepath.EvalSymlinks(keyDir)
462462
if err != nil {
463463
return nil, err
@@ -494,6 +494,8 @@ func LoadKeys(keyDir string) ([]key.SSHTPMKeys, error) {
494494
return nil
495495
}
496496

497+
k.ConfirmBeforeUse = confirm
498+
497499
keys = append(keys, k)
498500
slog.Debug("added TPM key", slog.String("name", path))
499501

cmd/ssh-tpm-agent/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Options:
4646
4747
--no-load Do not load TPM sealed keys by default.
4848
49+
--confirm-loaded Require confirmation via SSH_ASKPASS for all preloaded keys.
50+
4951
-o, --owner-password Ask for the owner password.
5052
5153
--no-cache The agent will not cache key passwords.
@@ -114,6 +116,7 @@ func main() {
114116
socketPath, keyDir string
115117
swtpmFlag, printSocketFlag bool
116118
installUserUnits, system, noLoad bool
119+
confirmLoaded bool
117120
askOwnerPassword, debugMode bool
118121
noCache bool
119122
hierarchy string
@@ -129,6 +132,7 @@ func main() {
129132
flag.BoolVar(&installUserUnits, "install-user-units", false, "install systemd user units")
130133
flag.BoolVar(&system, "install-system", false, "install systemd user units")
131134
flag.BoolVar(&noLoad, "no-load", false, "don't load TPM sealed keys")
135+
flag.BoolVar(&confirmLoaded, "confirm-loaded", false, "require confirmation for all preloaded keys")
132136
flag.BoolVar(&askOwnerPassword, "o", false, "ask for the owner password")
133137
flag.BoolVar(&askOwnerPassword, "owner-password", false, "ask for the owner password")
134138
flag.BoolVar(&debugMode, "d", false, "debug mode")
@@ -211,7 +215,7 @@ func main() {
211215
// We need to pre-read all the keys before we run landlock
212216
var keys []key.SSHTPMKeys
213217
if !noLoad {
214-
keys, err = agent.LoadKeys(keyDir)
218+
keys, err = agent.LoadKeys(keyDir, confirmLoaded)
215219
if err != nil {
216220
log.Fatalf("can't preload keys from ~/.ssh: %v", err)
217221
}

man/ssh-tpm-agent.1.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Defaults to _~/.ssh_.
4040
*--no-load*::
4141
Do not load TPM sealed keys from _~/.ssh_ by default.
4242

43+
*--confirm-loaded*::
44+
Require confirmation via _SSH_ASKPASS_ for all preloaded keys.
45+
4346
*-o, --owner-password*::
4447
Ask for the owner password.
4548

0 commit comments

Comments
 (0)