Skip to content

Commit 2b8f14d

Browse files
committed
add ability to whitelist an user for a single key
1 parent f3dbb79 commit 2b8f14d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cmd/up.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,20 @@ func NewCmdUp() *cobra.Command {
166166
}
167167
}
168168

169-
for _, authorizedKeysPath := range []string{
170-
filepath.Join(os.Getenv("HOME"), ".ssh", "authorized_keys"),
169+
authorizedKeysPaths := []string{
171170
filepath.Join(k.String("dir"), ".smallweb", "authorized_keys"),
172-
} {
171+
filepath.Join(k.String("dir"), ".smallweb", "authorized_keys"),
172+
}
173+
174+
if user := ctx.User(); user != "_" {
175+
authorizedKeysPaths = append(authorizedKeysPaths, filepath.Join(k.String("dir"), user, "authorized_keys"))
176+
}
177+
178+
for _, authorizedKeysPath := range authorizedKeysPaths {
179+
if _, err := os.Stat(authorizedKeysPath); err != nil {
180+
continue
181+
}
182+
173183
ok, err := validatePublicKey(authorizedKeysPath, key)
174184
if err != nil {
175185
if errors.Is(err, os.ErrNotExist) {

0 commit comments

Comments
 (0)