bag*_*har 6 ssh authentication
我想知道在建立 ssh 连接的幕后发生了什么,我的意思是直到我们从 Linux 机器登陆 Linux 的 shell。我知道密码不是在 ssh 连接中以纯文本形式发送的。那么他们如何加密连接。在这里我假设我没有生成我的公钥/私钥。我使用密码进行身份验证。所以我认为在保护连接之前不能交换密钥。我在谷歌和 serverfault 上搜索,但没有命中。我在 serverfault 中最接近的是这篇文章执行密钥协商时 ssh 到底发送了什么?.
上面的帖子假设用户通过公钥交换进行连接。但我正在寻找一种无需公钥/私钥即可保护连接的案例。即使在我输入密码之前,它如何加密连接。它使用什么来保护连接以便密码不发送纯文本?
RFC 4252解释了使用 SSH 进行身份验证的工作原理以及其中涉及哪些步骤。当然,规范阅读起来很麻烦,因此最简单的方法可能是ssh使用一个或多个详细 ( -v) 标志运行,因为它们会打印出所有调试输出来解释它在做什么。
这是示例案例的样子(我更改了用户名和主机名)。使用ssh -vv代替ssh -v将提供更多细节:
[user@gromp ~]$ ssh -v user@example.org
OpenSSH_5.5p1 Debian-6, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to example.org [1.2.3.4] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.8
debug1: match: OpenSSH_5.8 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'example.org' is known and matches the RSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: publickey
debug1: Trying private key: /home/user/.ssh/id_rsa
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: password
user@example.org's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
[user@example.org~]$
Run Code Online (Sandbox Code Playgroud)
当你第一次安装SSH并启动它时,它会为机器生成公钥和私钥,每个用户都是一样的。连接后,两台机器将交换它们的公钥部分(以纯文本形式)并使用它们来加密主机之间的通信。密钥交换后,通信将切换到加密模式。
在每个用户~/.ssh/known_hosts文件中,密钥将被存储并与下一次连接时发送的密钥进行比较。这就是如果您尝试连接到最近重新安装的机器时会出现错误的原因:这样做时您生成了一个新的机器密钥对,这与缓存的版本不匹配,这也可能意味着尝试连接攻击。
| 归档时间: |
|
| 查看次数: |
9379 次 |
| 最近记录: |