LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-31-2014, 09:49 AM   #1
johnmccarthy
Member
 
Registered: Jul 2010
Posts: 64

Rep: Reputation: 1
Cool Script performs an auto ssh login using a system generated rsa key


One of my general users wrote a script that generates an automatic ssh login using a system generated rsa key and the user hashed login; the hash is viewable by everyone. If the rsa user hash is indeed viewable can general users (basically everyone) copy and paste the hash and login using another persons user login account? If yes how is this possible? I ask since I want to be sure when I explain to the general user who wrote the script that it is not permitted and why.

For some reason I belive that it is possible but wanted to confirm with the experts since the user who wrote the script may be bias. I can provide more if anyone wishes.

As always a million thaks.
Johnny Mac
 
Old 12-31-2014, 10:09 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
An RSA keypair has a public half (which can safely be shown to anyone) and a private half (which should be known only to the owner). Typical filenames are id_rsa and id_rsa.pub .

The public key is used in ~/.ssh/authorized_keys as configuration to say access to this account with this key is allowed. It's id_rsa that he should be protecting.



There's also a kind of reverse situation where a whole lot of systems are allowed to interface to a service that does a limited amount of stuff and you want them all to have the private key (but this is uncommon).
 
Old 12-31-2014, 11:56 AM   #3
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
As said above, ssh can use public key encryption.

Whenever you generate ssh keys (or any public key for that matter) there is a public key and a private key, or asymmetric key.

This works in a special way:
The public key can encrypt any information so that only the private key may decrypt it. Note the public key cannot decode information encoded by the public key (very important)
The private key can sign any information and anyone with the public key may decode it.

This permits two important things.
First:
People using the public key know that only one person can access it.
People decoding the signed information know that only one person could of created it.

Why is this relevant to ssh? ssh works a bit like this:
The server has a copy of the clients public key (authorized keys), the client has a copy of the servers public key (known hosts)
The client sends a request to the server, encrypting it using the servers public key. No one but the server may access it.
The server obtains it, decrypts the message with its private key, and encrypts a symmetric key (same password to encode/decode)
It sends this to the client who then decrypts it. It attempts to connect to the server using the symmetric key.
If everything is ok, a encrypted connection is made.

Hopefully I wrote that clearly, what it means is this:
Anyone can have the public key, technically - you could post a public key and a public key encrypted message to a pastebin and expect total privacy.
The private key however, you must protect. If it is compromised, they are fully trusted to be the correct person.

If someone copies the public key and attempts to make a connection, the server will encrypt the symmetric key to the same public key, and the (lame) cracker will be foiled.

So there is no need to lock down the public key (or as you described - hashes) as it is only useful to the owner of the private key.
Permissions must reflect this, I believe if the private key (~/.ssh/id_rsa for example) has permissions above 600, ssh will refuse to run using it, for good reason.

Last edited by Miati; 12-31-2014 at 11:58 AM.
 
  


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
Auto SSH-login expect script creatorrr Linux - Software 7 10-26-2011 03:09 AM
Putty/SSH login failed when using RSA public key: 'Server refused our key' itsecx@gmail.com Linux - Server 10 10-04-2010 01:19 PM
ssh auto login script zerocool22 Linux - Server 4 05-13-2008 09:43 PM
SSH rsa key PB0711 Linux - Security 3 09-10-2006 03:57 PM
ssh RSA key thanat0s Linux - Security 3 09-29-2003 09:51 PM

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

All times are GMT -5. The time now is 11:01 AM.

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