When SSH(OpenSSH) client connects to SSH server, then SSH server provides its public encryption key(for example /etc/ssh/ssh_host_rsa_key.pub) to SSH client so that SSH client can encrypt data sent to SSH server and SSH server can decrypt this with its corresponding private key(for example /etc/ssh/ssh_host_rsa_key). Now when SSH server sends data to SSH client, then does it encrypt data with its private key and SSH client needs to decrypt this with the corresponding public key which it received at the start of the SSH connection? Or did SSH client provide its public key to SSH server and SSH server uses this to encrypt data and SSH client will use its corresponding private key to decrypt this data?

1 Answer 1


No. The protocol is more complicated then this and you can read the whole description in RFC 4253 and similar. The host key is not used as encryption key. The host key just verifies the authenticity of the host and prevents you from Man In the Middle attack. Similar is used identity key, which is used only for authentication.

The encryption keys are created based on the key exchange (usually diffie-hellman) and there are 6 of them derived from the key material provided by key exchange. You have separate encryption key, IV (Initialization vector) and MAC key for ensuring the integrity of each message. Also you have separate key for both direction (server->client, client->server).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .