Ubuntu – Is it possible to encrypt the communications via netcat

command linenetcat

I know that its possible to chat in linux terminal using netcat. I want to know whether it is possible to encrypt the netcat communications.

I did chat by listening on PC-1

nc -l 1234

And connecting to my IP on the other machine.

nc $IP 1234

Best Answer

It's possible - however I don't think nc does this itself: echo "Words" | gpg -e will produce an encrypted version on stdout; you can specify a receiving user as per usual.
If you pipe this to another copy of gpg as gpg -d then it asks for a passphrase - this will be remembered for a period, so enabling a conversation.

Therefore, echo "words" | gpg -e | nc target 4321 will send, and nc -l 4321 | gpg -d will listen.

Also, see this question which is similar.

Related Question