我们可以在 sshd_config 中提到 "AuthorizedKeysFile" 时使用通配符来拥有多个路径吗?
Can we use wildcard to have multiple paths while mentioning "AuthorizedKeysFile" in sshd_config?
我希望每个授权密钥文件有一个 public。
示例:
在目录 %h/.ssh/
- 对于 A,单独的文件 A_authorized_key 包含 public A
的密钥
- 对于 B,单独的文件 B_authorized_key 包含 public B
的密钥
ls %h/.ssh/ 将给出:
- A_authorized_key
- B_authorized_key
我知道我们可以在 authorized_keys
文件中写入两个 public 键,它会像一个魅力一样工作,但由于某些原因我希望它在单独的文件中。
那么我们可以写成AuthorizedKeysFile %h/.ssh/*
吗?
我们能做到吗?
没有。您不能在 AuthorizedKeysFile
中使用通配符。您可以使用多个文件,但不能使用通配符。
AuthorizedKeysFile
Specifies the file that contains the public keys used for user authentication. ...
但是您可以创建一个脚本,它将选择所有这些键并将它们提供给 ssh
,这将 运行 它作为 AuthorizedPrincipalsCommand
和 AuthorizedKeysCommandUser
:
AuthorizedPrincipalsCommand /path/to/script
AuthorizedKeysCommandUser root
脚本可以如下所示:
#!/bin/bash
DIR="~/.ssh/*"
cat `eval echo $DIR
但请注意,您的通配符也与用户的私钥匹配,触摸这些密钥绝不是一个好主意。
我希望每个授权密钥文件有一个 public。
示例:
在目录 %h/.ssh/
- 对于 A,单独的文件 A_authorized_key 包含 public A 的密钥
- 对于 B,单独的文件 B_authorized_key 包含 public B 的密钥
ls %h/.ssh/ 将给出:
- A_authorized_key
- B_authorized_key
我知道我们可以在 authorized_keys
文件中写入两个 public 键,它会像一个魅力一样工作,但由于某些原因我希望它在单独的文件中。
那么我们可以写成AuthorizedKeysFile %h/.ssh/*
吗?
我们能做到吗?
没有。您不能在 AuthorizedKeysFile
中使用通配符。您可以使用多个文件,但不能使用通配符。
AuthorizedKeysFile
Specifies the file that contains the public keys used for user authentication. ...
但是您可以创建一个脚本,它将选择所有这些键并将它们提供给 ssh
,这将 运行 它作为 AuthorizedPrincipalsCommand
和 AuthorizedKeysCommandUser
:
AuthorizedPrincipalsCommand /path/to/script
AuthorizedKeysCommandUser root
脚本可以如下所示:
#!/bin/bash
DIR="~/.ssh/*"
cat `eval echo $DIR
但请注意,您的通配符也与用户的私钥匹配,触摸这些密钥绝不是一个好主意。