CuriousMind
CuriousMind

Reputation: 8903

ssh between client and server : How does server decrypt the data send by client to it?

I am trying to understand SSH mechanics; as I understand, using ssh we can secure connection between a client and server.

A client will create private and public key (say using ssh-keygen); pass on public key to server.

Now, we have this flow:

Client -> Server; the client has both pair of keys, so if server sends data (which is being encrypted by public key, then the client can decrypt it); but how does server decrypt the data which is being sent from the client -> server; the client will use the public key to encrypt the data; since the server has only the public key, how does it decrypt the data which client sends to it?

Server -> Client; the server has only public key; so I think this is ok; the server will use the public key to encrypt the data, and then a client will use its private key to decrypt the data.

Upvotes: 1

Views: 736

Answers (1)

VonC
VonC

Reputation: 1323803

but how does server decrypt the data which is being sent from the client -> server

Because after the server is verified, both the parties negotiate a session key using a version of something called the Diffie-Hellman algorithm.
This algorithm is designed in such a way that both the parties contribute equally in generation of session key.
The generated session key is shared symmetric key i.e. the same key is used for encryption and decryption.

See more at "Understanding SSH workflow" from Mudit Maheshwari

And "SSH (Key gen)":

https://asecuritysite.com/public/ssh01.png

Upvotes: 4

Related Questions