服务器新手在这里和Mac上供参考。
所以我试图打破我和我的 LAMP 堆栈之间的 ssh 密钥身份验证,尽管我不能。换句话说,它只是给了我访问权限,但我不知道如何访问!这就是我所做的...
ssh-keygen -f foo_key
ssh -i /Users/me/.ssh/foo_key [email protected]
现在我可以访问了,接下来我从我的服务器
logout
。现在我想取消对这台计算机的访问。我尝试删除本地私钥和公钥,尝试删除 known_hosts
中的校验和,我尝试找到保存在 keychain access
中的密钥,但那里什么也没有。
那么这个认证信息保存在哪里了,很烦人。
感谢所有指导。
编辑
这里有一些详细信息,它现在似乎根本没有使用我的
foo_key
:
debug1: identity file /Users/me/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/id_ed25519-cert type -1
它甚至一开始就没有提供有关 RSA 密钥的准确信息:
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key:
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key:
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
另一个更新
运行 -vvv 不会给我提供比我已经发布的信息更有意义的信息。我不知道这是否与此有关,但我在
authorized_keys
中没有 ~/.ssh/
文件。我创建了一个并生成了一些新密钥,其中没有存储任何内容。
我只需要知道为什么即使我已经删除了我在机器上生成的密钥的所有证据,我仍然可以继续访问我的服务器。不敢相信这并不常见!?
值得注意的是,我没有默认使用
id_rsa
键,我专门创建了自定义键并希望继续使用它们。
您需要从本地计算机中删除
.ssh/foo_key
和 .ssh/foo_key.pub
,并从服务器上的 .ssh/authorized_keys
中删除公钥条目。
最后一步是关键。
编辑: 另外,您可以使用
-v
选项获得更详细的输出,以准确查看其身份验证方式。
您是否在 sshd_config 中进行了任何更改以禁止未经公钥身份验证的连接?
如果不是,你必须更改行
PasswordAuthentication yes
到
PasswordAuthentication no
然后使用您拥有的任何 init 系统重新启动 sshd。
从我的 Mac 本地删除密钥并重新启动后,才会撤销访问权限。因此它必须以某种方式缓存连接凭据。不知道如何,但以防万一有人遇到同样的事情。
在我的例子中,密钥由 ssh-agent 缓存