LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 09-15-2012, 07:40 PM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
shared key vs signed certificate in one use case


I'm looking for any good reason not to use a shared key for a specific secured data transfer case. So far I don't find any good one. But at least one person I have described this to seems overly fearful of a shared key. I just think they are reacting to the fact that a shared key is not suitable in the general cases, but have not analyzed how it would apply in this case I describe below:

The use case is a one time data transfer. The scenario is a user logged in to two separate remote computers via a slow connection using ssh. There is a need to transfer a large volume of data from one remote host to the other. These remote hosts are located apart from each other requiring use of the internet to reach each other directly. The ssh connections might be as slow as mobile 2G or even dial-up. The data to be transfered between the remote hosts might be a terabyte in size. You simply would not even think of transferring it down one ssh connection and up the other. So a direct connection is clearly essential, and it must be secured via encryption. Preventing others from seeing the data is the primary concern, but undetected alterations are also a concern.

The data transfer needs to be spontaneous without any complex setup to be performed, such as starting an ssh daemon. Use of root permissions is unavailable. Also, creating cross signed certificates is not practical.

I believe in this scenario, a script that sets up a networked pipeline on these two remote machines, utilizing an encryption cipher like aes-256-cbc available in a tool like openssl would be suitable. The user would provide a randomly chosen string to each remote machine where it is safe to do so, where the openssl program ends up getting that key. The data would be compressed and encrypted on the source machine, transmitted over a TCP connection to the destination machine, where it would be decrypted and uncompressed.

The question:

Is there any reason that the use of a shared secret key between these remote hosts is not appropriate? Is there any reason to justify requiring the greater complexity of setting up a public-key SSL/TLS certificate for this case?

Last edited by Skaperen; 09-15-2012 at 07:44 PM.
 
Old 09-16-2012, 07:48 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Your entire scenario depends on the security of that key, and getting it from place to place. Maybe the SSL protocol is just what you really want. This protocol can negotiate a secure communication with anyone who wants to connect. The two parties can then authenticate themselves any way they wish over the now-secure connection.
 
Old 09-16-2012, 12:27 PM   #3
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by sundialsvcs View Post
Your entire scenario depends on the security of that key, and getting it from place to place.
Of course it depends on the security of the key. Any crypto system depends on the security of its keys.

Quote:
Originally Posted by sundialsvcs View Post
Maybe the SSL protocol is just what you really want. This protocol can negotiate a secure communication with anyone who wants to connect. The two parties can then authenticate themselves any way they wish over the now-secure connection.
But this is what I do NOT want. I do NOT want "anyone who wants to connect" to be able to, or at least able to get anything useful out of it. This is NOT a "secure web server" scenario where I let anyone have the data even though the connection is secure (security in this case serves a different purpose).

The sender needs to make sure only the authorized receiver will be able to get the data in the clear. The receiver needs to make sure only data from the authorized sender is being received. We are familiar with how that happens with SSL through use of signed server certificates and client certificates (though clients certificates are rarely used ... login passwords in an assumed MitM-safe channel are used).

But in my scenario, the SSL setup is not in place.

If the data were of a small volume, a reasonably secure scenario can be set up through SSH ... although this requires anticipation by the person that started the two SSH sessions. The SSH login to the sender host could have been
Code:
ssh -R localhost:12345:localhost:12345 user@remote-send
while the SSH login to the receiver host could have
Code:
ssh -L localhost:12345:localhost:12345 user@remote-recv
(note -R vs -L). On the receiver, the user would do
Code:
socat tcp4-listen:12345 stdout | tar xpfz -
while on the sender, the user would do
Code:
tar cfz - data | socat stdin tcp4:localhost:12345
The sender would create a tarball of data and pass it to socat which connects to localhost port 12345. Then the sshd in the remote-send host would create the ssh forwarding channel in reverse back to the client host and make a connection to port 12345 on the client. The other ssh would be listening and create the ssh forwarding channel out to the remote-recv host, and connect to port 12345 there. The socat program would be listening to port 12345 there and pass the data to the tar program in the pipeline. There are three uses of port numbers and they do not have to be the same number.

Now this is fine for cases where the data is not too small and the connections to the remotes from the client are of sufficient bandwidth.

But the scenario I explained is one where the above SSH pipelining/forwarding scheme puts too much burden on the SSH connections from the client. So I want to go direct. And I want to do it in as simple a way as possible. However, it is OK to have a script implemented to carry this out and ready to go on each remote host. Such a script is something that can be shared among the community and easily put anywhere ahead of time.

However, a certificate setup for SSL would not be so easily done on the fly.

The scenario I am suggesting is a script that can be given the cipher key on the command line or in response to a prompt. The user at the client machine can simply make up a random key and type it in on each host she is connected to when prompted (or generate something stronger and copy/paste it in). The trust relationship between the two hosts is establish by the user typing/pasting in this key, and only for the duration of time using this key.

What I see is that the above is AS GOOD AS any other trust relationship, particularly because it is a one time event and not depending on a key that is BOTH shared AND stored.

I have a little toy/tool that can make the keys for me (originally for making passwords, but it will go to an extreme if asked to):
Code:
lorentz/phil /home/phil 31> mkpw 72
pgcqyAXLXbxJ?xpu4OmH.nO2e.kKT=bB@s-ftv5Ol?V21XxK_9,l0EFz_uSoP&q5pDoVPYl:
lorentz/phil /home/phil 32>
And if you don't have my tool, there is always:
Code:
lorentz/phil /home/phil 32> uuidgen
36f8ae69-9abc-4aaf-b63d-7f8773369c2f
lorentz/phil /home/phil 33>
though it is not as strong.

Can you show how the scripts executed on the two remote hosts would establish trust in a simple way so the user only needs to run one command on each end? I do not think this is possible.
 
Old 09-16-2012, 03:22 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
You're proposal is essentially the classic establish a secure channel (usually using asymmetric keys, here via ssh which may also use asymmetric keys) and distribute a shared session key over it. SSL does something similar.

Quote:
The scenario I am suggesting is a script that can be given the cipher key on the command line or in response to a prompt. The user at the client machine can simply make up a random key and type it in on each host she is connected to when prompted (or generate something stronger and copy/paste it in). The trust relationship between the two hosts is establish by the user typing/pasting in this key, and only for the duration of time using this key.
I would suggest having the script generate a random key, don't leave it up to the user. The user shouldn't need to generate the session keys any more than they do for the ssh or SSL session keys.
 
Old 09-16-2012, 05:05 PM   #5
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by ntubski View Post
You're proposal is essentially the classic establish a secure channel (usually using asymmetric keys, here via ssh which may also use asymmetric keys) and distribute a shared session key over it. SSL does something similar.
Yes, that seems what it is. Except that the "distribute" part as it applies to the "SSL does something similar" is at best awkward. It might help if SSH itself (or a front end to it) would take care of that in some way.

Quote:
Originally Posted by ntubski View Post
I would suggest having the script generate a random key, don't leave it up to the user. The user shouldn't need to generate the session keys any more than they do for the ssh or SSL session keys.
Which script? The one on the remote sender? The one on the remote receiver?

The client machine that runs ssh to the two remotes? If I do that at the client, it will need to pass the same key to ALL the hosts (there might be hundreds, but the transfer only needs to be done by two of them, while another has been broken into).

Some mechanism for the script on the remotes to communicate back to the client and address the other remote specifically and do a key exchange that way could make more sense. It would be stronger than just a random shared string. And it could now be on the time scale as the cipher in SSL (which ultimately is a shared key of rather short duration). I could have SSH always set up a reverse channel back to a client based "key trader" server/agent.

But if I don't have that mechanism? Just how weak is it to have the user just think up a pass phrase and use that ... once?
 
Old 09-16-2012, 05:44 PM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by Skaperen View Post
Which script? The one on the remote sender? The one on the remote receiver?

The client machine that runs ssh to the two remotes? If I do that at the client, it will need to pass the same key to ALL the hosts (there might be hundreds, but the transfer only needs to be done by two of them, while another has been broken into).
I was thinking the script would be run from the client running ssh using a key per transfer, something like:
Code:
keyname=key.$(date).$random_id
generate_key $keyname
scp $keyname remote_send
ssh remote_send "encrypt; send to remote_recv; delete $keyname"
scp $keyname remote_recv
ssh remote_recv "decrypt; delete $keyname"
delete $keyname
Quote:
Just how weak is it to have the user just think up a pass phrase and use that ... once?
2 possible weaknesses occur to me:
  • If the user is actually just thinking up a pass phrase they might choose a dictionary word, or reuse an old password. If you have very security conscious users (does that ever happen?) using mkpw 72 you're probably fine.
  • The bad guy asks for the password
 
Old 09-17-2012, 12:07 PM   #7
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by ntubski View Post
I was thinking the script would be run from the client running ssh using a key per transfer, something like:
Code:
keyname=key.$(date).$random_id
generate_key $keyname
scp $keyname remote_send
ssh remote_send "encrypt; send to remote_recv; delete $keyname"
scp $keyname remote_recv
ssh remote_recv "decrypt; delete $keyname"
delete $keyname
OK, the user could either start a 2nd pair of sessions or drop out of the existing ones and restart them (easier if they run screen at the remote as I do, but not everyone does).

2 possible weaknesses occur to me:
  • If the user is actually just thinking up a pass phrase they might choose a dictionary word, or reuse an old password. If you have very security conscious users (does that ever happen?) using mkpw 72 you're probably fine.
  • The bad guy asks for the password
The password usage would be to give it to the program doing the encryption, and likewise the one doing the decryption. The "openssl" program might prompt for it but that is within the ssh session, not some web site being accessed. If the MitM is in your ssh session, you have other issues to deal with, first.

Here is what I've put together so far around this idea:
http://wiki.slashusr.net/documentation/scripts/cpionet
http://wiki.slashusr.net/documentation/scripts/tarnet

What I am thinking of changing is to have one end generate a random password and output that with instructions to copy it to the other machine. The listen side needs to be run first, so that's where it would be generated.
 
Old 09-17-2012, 01:02 PM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by Skaperen View Post
The password usage would be to give it to the program doing the encryption, and likewise the one doing the decryption. The "openssl" program might prompt for it but that is within the ssh session, not some web site being accessed. If the MitM is in your ssh session, you have other issues to deal with, first.
I was thinking more about phishing than MitM, but upon reflection it seems unlikely given the way passwords are being used here.

Seems a bit weird to have 2 identical-except-for-script-name pages.

Quote:
What I am thinking of changing is to have one end generate a random password and output that with instructions to copy it to the other machine. The listen side needs to be run first, so that's where it would be generated.
I think my suggested script would be more convenient for the user (no need to copy & paste passwords), but maybe there is some limitation in your setup that prevents it from working?
 
Old 09-18-2012, 04:29 PM   #9
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by ntubski View Post
Seems a bit weird to have 2 identical-except-for-script-name pages.
Neither cpio nor tar are perfect solutions. So I made it both ways and documented each.

Quote:
Originally Posted by ntubski View Post
I think my suggested script would be more convenient for the user (no need to copy & paste passwords), but maybe there is some limitation in your setup that prevents it from working?
It depends on port forwarding, which may be disallowed in some locations (especially where they do bureaucratic security over technical security).
 
Old 09-19-2012, 08:49 AM   #10
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by Skaperen View Post
Neither cpio nor tar are perfect solutions. So I made it both ways and documented each.
Maybe you could combine the documentation pages? Or maybe you could actually combine the command: instead of cpionet and tarnet, have one command that takes cpio or tar as an argument.


Quote:
It depends on port forwarding,
I don't think that's the case.
 
Old 09-19-2012, 03:59 PM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Please bear in mind that the SSL/TLS protocol does not have to be "open." It does support certificate-based client authentication.

It's also not the only secure-tunnel protocol out there. VPN of course is another. SSH tunneling is a distant third.

In any case, you want to use an existing, well-understood industry standard tunneling protocol, which is easily supported by your hardware. You don't want to roll your own. Once you have established the secure connection, the two sides must still authenticate with one another. Then, they can exchange information through whatever methods you please, all through the secure tunnel which neither of them has to secure further.

I invariably and strongly encourage a certificate-based approach, and here's an easy example why. When you go into your workplace, there's no one there saying, "say the magic word." No, you swipe your badge. You can't copy the badge. If you lose it, or get fired or whatever, that specific badge immediately is made useless. No one else is inconvenienced. The company can specify exactly what that unique badge is good for, and can easily change that profile at any time.

Password-protected certificates are strong additional protection because they are based on strong encryption of the key contents. But you still have to possess a valid, one-of-a-kind key, in addition to having the means to unlock it.

Last edited by sundialsvcs; 09-19-2012 at 04:08 PM.
 
Old 09-21-2012, 11:10 PM   #12
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by sundialsvcs View Post
It's also not the only secure-tunnel protocol out there. VPN of course is another. SSH tunneling is a distant third.
Is that because of its use of TCP?

Quote:
Originally Posted by sundialsvcs View Post
In any case, you want to use an existing, well-understood industry standard tunneling protocol, which is easily supported by your hardware. You don't want to roll your own. Once you have established the secure connection, the two sides must still authenticate with one another. Then, they can exchange information through whatever methods you please, all through the secure tunnel which neither of them has to secure further.
I have not seen existing software that applies to my use case. Nevertheless, what I have put together uses openssh encryption. The data is encrypted, so it cannot be spied on. The data must be decrypted to be useful to whoever gets it. A MitM attack is just a DoS attack (and not DDoS).

Quote:
Originally Posted by sundialsvcs View Post
I invariably and strongly encourage a certificate-based approach, and here's an easy example why. When you go into your workplace, there's no one there saying, "say the magic word." No, you swipe your badge. You can't copy the badge. If you lose it, or get fired or whatever, that specific badge immediately is made useless. No one else is inconvenienced. The company can specify exactly what that unique badge is good for, and can easily change that profile at any time.
That doesn't match my use case. I'm not going to analyze that example as to whether that is a use case for certificate-based ... I'll just assume it is. But it only shows there is at least one use case for a certificate-based approach (I know there are many). But I don't see where the one I'm trying to do is.

Quote:
Originally Posted by sundialsvcs View Post
Password-protected certificates are strong additional protection because they are based on strong encryption of the key contents. But you still have to possess a valid, one-of-a-kind key, in addition to having the means to unlock it.
Yes. So how would the quickie large file transfer case work with clients to 2 remotes?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Verify return code: 19 (self signed certificate in certificate chain) tikit Linux - Server 1 04-10-2012 05:21 PM
how to create signed (not self signed) certificate for Apache ? dlugasx Linux - Server 4 12-16-2011 10:08 AM
Generating a Self Signed SSL Certificate carlosinfl Linux - Server 2 07-22-2009 03:39 PM
ssl self signed certificate dreamer.redeemer Linux - Security 2 02-02-2008 11:31 PM
How do I create a self signed SSL certificate? mongoose Linux - Software 2 04-15-2003 06:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration