【问题标题】:Can still access LAMP server, even after deleting local ssh keys即使在删除本地 ssh 密钥后仍然可以访问 LAMP 服务器
【发布时间】:2016-11-08 12:21:35
【问题描述】:

服务器新手在这里和mac上供参考。

所以我试图打破我和我的 LAMP 堆栈之间的 ssh 密钥身份验证,尽管我做不到。换句话说,它只是让我访问,我不知道如何!这是我所做的......

  • 通过终端创建密钥:ssh-keygen -f foo_key
  • 将 pub 密钥粘贴到我服务器上的正确位置...
  • 通过终端 SSH 进入:ssh -i /Users/me/.ssh/foo_key root@x.x.x.x
  • 要求输入我在设置时选择的密码,输入正确。

所以现在我可以访问了,接下来我从我的服务器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 并没有给我任何比我已经发布的更有意义的信息。我不知道这是否与它有关,但我在~/.ssh/ 中没有authorized_keys 文件。我创建了一个并生成了一些新密钥,其中没有存储任何内容。

我只需要知道为什么即使我已经删除了我在机器上生成的密钥的所有证据,我仍然可以继续访问我的服务器。不敢相信这不常见!?

值得注意的是,我没有默认使用 id_rsa 键,我专门创建自定义键并希望继续使用它们。

【问题讨论】:

  • 发布详细日志。它会告诉你那里发生了什么。
  • 我发了一些,有用吗?
  • 您正在使用某个密钥进行身份验证。使用-vvv 应该会为您提供更多信息,并希望它还能从哪里获取密钥。
  • 嗯,再次感谢,但没有任何有意义的事情。

标签: ssh lamp ssh-keys


【解决方案1】:

您是否对 sshd_config 进行了任何更改以禁止未经公钥身份验证的连接?

如果不是,你就得换行说

PasswordAuthentication yes

PasswordAuthentication no

然后你用你拥有的任何 init 系统重新启动 sshd。

【讨论】:

  • 我会试一试,让你知道我的进展情况。
  • 这与问题完全无关。
  • 在 OPs 编辑之前它不是或不是无关的。如果你不关闭PasswordAuthentication,那么不管有没有私钥,你都可以登录服务器。
【解决方案2】:

您需要从本地计算机中删除 .ssh/foo_key.ssh/foo_key.pub,并从服务器上的 .ssh/authorized_keys 中删除公钥条目。

最后一步是关键。

编辑:此外,您可以使用-v 选项获得更详细的输出,以查看它是如何进行身份验证的。

【讨论】:

  • 服务器上是否仍然存在 pub 密钥肯定没关系?我在本地删除了公共和私人,仍然可以获得访问权限,这是我提出问题的奇怪基础。
  • @Capio 没错,只是想确保涵盖所有步骤。 ssh -vvv 应该能够告诉您它最终使用的密钥/身份验证方法。并检查 authorized_keys 文件是否有可能添加的其他密钥的任何线索。
【解决方案3】:

从我的 Mac 本地删除密钥并重新启动后,它才会撤销访问权限。所以它必须以某种方式缓存连接凭据。不知道怎么做,但万一有人遇到同样的事情。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-08
    • 1970-01-01
    • 2018-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    • 2014-12-06
    相关资源
    最近更新 更多