Ran*_*gle 17 command-line password seahorse
我发现这篇关于从命令行从 gnome 密钥环获取密码的帖子(如何从终端中的密钥环获取密码以用于脚本?),我发现秘密工具是要走的路。很高兴我可以使用 secret-tool 存储密码,但我似乎无法弄清楚如何查找使用 seahorse 存储的现有密码,这正是我真正希望做的。我不知道我需要使用什么属性和值来查询它们,并且手册页对这些可能是什么相当模糊。
Vae*_*lus 14
我制作了一个实用程序lssecret,它使用 libsecret 列出所有项目,包括所有 GNOME 密钥环项目。看起来 libsecret 会自动为每个项目添加一个键值对,但 Seahorse 没有在 GUI 中显示它们。以下是 lssecret 的一些示例输出:
Collection: Login
Item: Test Password
Secret: Tr0ub4dor&3
Key: xdg:schema
Value: org.gnome.keyring.Note
Item: secret-tool item
Secret: s3cret-t00l
Key: my key
Value: my value
Key: xdg:schema
Value: org.freedesktop.Secret.Generic
Item: Unlock password for: cueball@xkcd.com
Secret: correct horse battery staple
Key: unique
Value: ssh-store:/home/cueball/.ssh/id_rsa
Key: xdg:schema
Value: org.freedesktop.Secret.Generic
Item: Network secret for GenericSSID/802-1x/password
Secret: S3cureW1f1Passw0rd
Key: setting-name
Value: 802-1x
Key: connection-uuid
Value: 6a762552-04b3-cd05-45ba-586688e0a029
Key: xdg:schema
Value: org.freedesktop.NetworkManager.Connection
Key: setting-key
Value: password
Run Code Online (Sandbox Code Playgroud)
GNOME 密钥环将每个密钥环作为一个集合存储在秘密服务中。您可以在输出中看到默认密钥环 Login。项目代表:
secret-tool store --label="secret-tool item" "my key" "my value"
,然后在提示中键入“s3cret-t00l”。如您所见,使用 Seahorse 添加到密钥环的密码具有“xdg:schema”和“org.gnome.keyring.Note”的键值对。您可以使用secret-tool search --all xdg:schema org.gnome.keyring.Note
.
Ran*_*gle 12
好吧,在进一步调查之后,看起来 seahorse没有为存储的密码分配任何属性(我很确定 secret-tool 找不到没有任何属性可查找的密码)。我相信是这种情况的原因是,在海马中创建一个之后,我查看了属性->详细信息并且没有详细信息(即属性)。不过,我在 seahorse 中发现了其他有详细信息的内容,我可以使用这些属性在秘密工具中查找它们。
解决方案似乎是使用 secret-tool 创建密码,为以后的唯一查找分配适当的属性。由于他们都在后台使用 gnome-keyring,因此在您在 secret-tool 中创建新密码的那一刻,新密码就会出现在 seahorse 中。
Gnome-keyring 似乎很乐意创建多个具有完全相同标签的密码(只是属性不完全相同,如果它们完全相同,它将替换它),所以一旦你重新创建它,你就可以删除来自海马的旧的无用的。
$ secret-tool store --label=DomainPassword user sjohnson domain some.domain
Password: thisismypa$$w0rd
$ secret-tool lookup user sjohnson domain some.domain
thisismypa$$w0rd
Run Code Online (Sandbox Code Playgroud)
我最初不想使用 secret-tool 存储密码的原因是我不知道如何通过 secret-tool将其设置为登录密码(登录时可用)。看起来,只要“登录”是您的默认密钥库,secret-tool 就会将其存储在那里。