我想知道在build立一个ssh连接的幕后发生了什么,我的意思是直到我们从一台Linux机器登陆Linux的shell。 我知道密码不是以纯文本forms在ssh连接中发送的。 那么他们做什么来encryption连接。 在这里,我假设我没有生成我的公/私钥。 我使用密码进行身份validation。 所以我认为在确保连接之前不能进行密钥交换。 我search谷歌和服务器故障,但没有命中。 在服务器错误最近我得到了这篇文章什么是确切的时候执行密钥协商ssh发送? 。
以上post假定用户正在通过公钥交换进行连接。 但是我正在寻找一个没有公钥/私钥的安全连接的情况。 即使在input密码之前,它如何encryption连接。 它使用什么来保护连接,使密码不发送纯文本?
当您安装SSH并首次启动时,它将为机器生成公钥和私钥,这对每个用户都是一样的。 连接后,两台机器将交换其公钥部分(明文),并使用它们encryption主机之间的通信。 密钥交换后,通信将切换到encryption模式。
在每个用户~/.ssh/known_hosts文件中,密钥将被存储并与下一次连接时发送的密钥进行比较。 如果您尝试连接到最近重新安装的计算机,则会出现错误:这样做时,您已经生成了一个新的计算机密钥对,这与caching版本不匹配,也可能意味着尝试攻击。
RFC 4252解释了如何使用SSH进行authentication,以及涉及哪些步骤。 当然,这个规范读起来很麻烦,所以最简单的方法可能是用一个或多个verbose( -v )标志运行ssh ,因为它打印出所有debugging输出,解释它正在做什么。
这是一个示例(我更改了用户名和主机名)的样子。 使用ssh -vv代替ssh -v将提供更多的细节:
[user@gromp ~]$ ssh -v [email protected] 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 [email protected]'s password: debug1: Authentication succeeded (password). debug1: channel 0: new [client-session] debug1: Requesting [email protected] debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 [[email protected]~]$