Does public key cryptography encrypt data in both directions with SSH?
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Does public key cryptography encrypt data in both directions with SSH?
Let's say that I have an SSH tunnel and my private encryption key. The server has my public key which it uses to encrypt data sent to me. Does the information that I send to the server also get encrypted? Does the SSH server send me it's own public key through the downstream when I connect to it?
wulp,
Once you put your public key that was created with ssh-keygen (it is at ~/.ssh/id_rsa.pub) on the server at ~/.ssh/authorized_keys, then log out and log in again, SSH will use the files in the ~/.ssh directory to authenticate you. During the session setup, a session key is created and shared. Now you will no longer be using public/private asymmetric encryption once the session key (actually keys for each direction, client-to-server and server-to-client, and separate keys for encryption and for integrity checking), meaning the symmetric secret, is shared. Bulk encryption is done using the session keys, not the public and private keys.
If you do an "ssh -vvv user@server", you can see everything done in the session setup. It will help you if you can follow along to see what each of those lines in the debug dump means. I recommend that you buy the book "SSH, The Secure Shell: The Definitive Guide" (Second Edition) ISBN-13: 978-0-596-00895-6.
You can prove to yourself that data are encrypted in both directions by setting up an SSH session in one terminal window and, in another terminal window, running "snort -vde" as root.
Public-key encryption (PKI) techniques are computationally expensive, and would be weakened if very large amounts of data were sent using them. Therefore, PKI is used only in the initial "handshaking" that is used to initiate the conversation -- and that may from time to time thereafter be used during the conversation. This handshaking establishes:
The mutually acceptable identity of the two parties who are communication. ("Alice, is that really you?")
The conventional cipher algorithm that is to be used.
The secret key that is to be plugged into that cipher.
You see similar techniques being used in simpler crypto situations, such as the ones that are commonly used to secure (sic... ) wireless networks. The encryption hardware is built into the device itself; the weakness of the original technique was that it used a single fixed, unchanging key. (You could brute-force the algorithm and, once you had done so, you could eavesdrop on everybody in the coffee shop.) The replacement algorithms use a software agent to conduct a preliminary key-exchange. The same fast hardware is still used, but everyone's key de jour is different and subject to change.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.