# Is there any point to encrypting a file if it's transferred via ssh?

Suppose I have two machines which can ssh into each other. Is there very little point in using gpg with a password protected symmetric cipher to transfer a sensitive file, and going to the effort of sharing the password - over, say, an encrypted call?

I realize that theoretically the ssh communication could be compromised without the password which protects the encrypted file being compromised, but what I'm asking is does the whole system need an overhaul if I'm leaning on ssh being secure for sensitive file transfer?

• Welcome to Cryptography. Do both systems have single users? What are your risks? If both systems are attackable, then having encryption on the transmitted files is a good idea. – kelalaka Feb 21 '19 at 7:52
• If authenticity is very important, then you can exchange the SSH fingerprint over the phone. – forest Feb 21 '19 at 8:05

If you had a system like this:

$$$$\text{you} \longleftrightarrow \text{your network} \longleftrightarrow \text{shared host} \longleftrightarrow \text{friend's network} \longleftrightarrow \text{friend}$$$$

• Your use of ssh defends against an eavesdropper or forger on your network.
• Your friend's use of ssh—if your friend is using ssh instead of, oh, I dunno, rlogin or rcp—defends against an eavesdropper or forger on your friend's network.
• The use of gpg with a password transmitted out-of-band to encrypt the file defends against an eavesdropper—but not a forger!—on the shared host.

Why no defense against a forger on the shared host? Nobody bothered to teach OpenPGP about symmetric authenticated encryption. You could use the scrypt(1) utility instead, which does use authenticated encryption.

How could there possibly be an eavesdropper on the shared host? The eavesdropper might come in the form of the administrator of the VPS you're using for your shared host, who has access to the raw disk. The eavesdropper might come in the form of an automatic backup system which persists the file much longer than you intended.

But, on a more careful reading of the first eleven words you actually wrote, I see that you actually have a system like this:

$$$$\text{your machine} \longleftrightarrow \text{internet} \longleftrightarrow \text{friend's machine}$$$$

Conceivably you might have different applications and daemons running with different privileges, and your user account on your friend's machine might be more vulnerable than your friend's user account.

But there's not much else that gpg adds beyond (a) a hedge against bugs in ssh or breakthroughs in breaking DH (like a network eavesdropper with a quantum computer) that don't apply to your out-of-band channel, and (b) a usability nightmare.

• I believe the OP's scenario is that they and their friend can ssh directly into each other's machines – Conrado Mar 7 '19 at 11:43
• So it is. Apparently this vulture can't read very well. – Squeamish Ossifrage Mar 7 '19 at 16:19