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 09-02-2009, 06:39 AM   #1
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Rep: Reputation: 15
Question SSH public key authentication


Hello,

I've done some research into setting this up. I've found many helpful articles but a few (probably very basic) things still elude me. Here is my understanding of things.

So basically (bear with me here):

- I generate a key pair and store my public key on the server.
- When I connect to the server, I have to send it something encrypted with my private key, which I'll be calling 'the message'.
- I hash the (encrypted by my private key) message using MD5 of SHA. The hashed thingy is called a message digest.
- Then I encrypt my already encrypted message + the message digest using the servers public key. I'll call this 'the package'.
- The server decrypts the package using its private key, hashes my (still encrypted) message and compares this to the digest I sent it.
- If that checks out it tries to decrypt my message using my public key.

I assume I'm correct so far, please correct me if you find any mistakes. I do already have questions

- What is the password protection that can be applied to my private key? =>>I'm guessing AES or any other symmetric encryption algorithm?
- Why don't I have to store the server's public key since it is storing mine. How else can I sent it the encrypted package?
- Why aren't certificates used? I understand they are used to automate the public key exchange?

A whole mouthful to read. I hope it made some sense

Regards,

Jeroen

Last edited by Jeroen1000; 09-02-2009 at 06:44 AM.
 
Old 09-02-2009, 07:13 AM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
A bit confusing. What is it you are trying to do? The title indicates SSH public key authentication, but the text is a paraphrase that sounds like you are trying to encrypt a message and send it to the server and manually deal with things. If the title is accurate, the best howto I've found (and been using for years) is http://sial.org/howto/openssh/publickey-auth/. sial also has a number of other excellent howto's -- e.g. ssl certs, etc.

Typically, if you keep your explanations very explicit by using command line text (for example, "I used `ssh-keygen -q -f ~/.ssh/id_rsa -t rsa` and then entered a blank pass phrase."), then it is easier for people to see what you are doing and help out.
 
Old 09-02-2009, 09:18 AM   #3
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Original Poster
Rep: Reputation: 15
I'm trying to understand what happens when you initiate an SSH session. My head is a bit full from reading too much I'm afraid. Then I tend to ramble confusing things.

The thing that confuses me the most is why certificates are not used (self-signed or 'real' official ones, doesn't matter for the intended purpose).
 
Old 09-02-2009, 09:27 AM   #4
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 782
Blog Entries: 8

Rep: Reputation: 158Reputation: 158
It seems you're confused with SSH, PKI concepts, and (G)PGP.

I suggest just focusing on one subject at a time. Segregating the three will be less confusing. They also warrant segregation, as they are three separate items of discussion and share no practical part in implementation.

As choogendyk stated, what is it that you're trying to achieve?
 
Old 09-03-2009, 01:01 AM   #5
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Original Poster
Rep: Reputation: 15
I've figured out the certifcate thing. Seems to be working like a charm (the server already had a keypair generated by my DDWRT router itself which is running some sort of embedded linux)

Unixfool, I'm indeed trying to understand the concepts behind it more thoroughly. Sure it works and I don't need to know how persé. But nonetheless, I'm very interested in the subject and I hate using things I do not understand.

I understand the public/private key concept is only for authentication only (+ to agree on a mutual symm. key). Whereas the symmetric key is for session encryption. The hashes are to verify no one has tampered with the packets. I'm still unsure what HMAC does and how Diffie-hellman fits in all of this.

The last two subjects are still a bit over my head:-).

Last edited by Jeroen1000; 09-03-2009 at 01:02 AM.
 
Old 09-03-2009, 06:26 AM   #6
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
Wikipedia is pretty good in the technology area. Their ssh page has a fair bit of detail on how it works. It gives you all the RFC's. Of course, if you really want to understand it, you might want to get the O'Reilly book.
 
Old 09-03-2009, 08:26 AM   #7
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 782
Blog Entries: 8

Rep: Reputation: 158Reputation: 158
Quote:
Originally Posted by choogendyk View Post
Wikipedia is pretty good in the technology area. Their ssh page has a fair bit of detail on how it works. It gives you all the RFC's. Of course, if you really want to understand it, you might want to get the O'Reilly book.
The O'Reilly book on SSH is positively awesome! I bought the book a few years ago and it is still very useful.
 
Old 09-04-2009, 01:34 AM   #8
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Original Poster
Rep: Reputation: 15
Are we talking about this one? There is a second edition too now
600+ pages about the shell. I'm baffled
http://oreilly.com/catalog/9780596008956/
 
Old 09-04-2009, 06:54 AM   #9
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
Yes. That's the book. Baffled? Well, if you click on the picture of the book on that link, you can cycle through the table of contents and actually browse through and read some of the contents. Given your attempts to understand what goes on underneath, I wouldn't think you should be surprised at 600+ pages about secure shell.
 
Old 09-04-2009, 07:32 AM   #10
vishesh
Member
 
Registered: Feb 2008
Distribution: Fedora,RHEL,Ubuntu
Posts: 661

Rep: Reputation: 66
We can access other machine without putting password every time. ssh provide option to put user public key as authorized key on machine which user want to access without entering password every time.
Following simple steps are required to do this
root@machine1#ssh-keygen
...
(press enter whenever ask for passphrase)
ssh-keygen generate private(id_rsa) and public key(id_rsa.pub) file for that user (here root)

Now put root public key file (id_rsa.pub) on machine which you want to access (here machine with ip 192.168.11.51)

root@machine1#ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.11.51
...
enter "yes" if ask for adding machine
specify password for root user of 192.168.11.51 whenever ask ..

cheers, setup is complete now, now access it

Last edited by vishesh; 09-06-2009 at 10:46 PM.
 
Old 09-04-2009, 08:27 PM   #11
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
vishesh, the link to your blog already appears in your signature, so there's no need to post it. I've noticed you've done this on multiple occasions within a very short time frame. Please understand that this kind of behavior can be interpreted as an attempt to draw traffic to your site, in which case your LQ privileges could be affected. Contact me via email if you have any questions/comments regarding this matter (do NOT use this thread).
 
Old 09-07-2009, 01:11 AM   #12
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Original Poster
Rep: Reputation: 15
choogendyk ane unixfool, it does cover all I wanted to know. I haven't read it yet but did place the order. I'm very pleased about this recommendation, thank you all
 
Old 09-07-2009, 04:14 AM   #13
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
It would be better configuring ssh to not allow root logins. Logging in as root on the remote machine is bad practice. I edited /etc/X11/xdm/sys.xsession, removing the comment from the "usessh" line. A subsequent part of the script will then prompt for the passphrase when logging in.
 
  


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
ssh public key authentication teacup Linux - Networking 4 11-27-2011 11:27 PM
Public key authentication with ssh elnacho12 Linux - Networking 3 12-18-2007 08:38 AM
Public Key Authentication with SSH edafe Ubuntu 1 08-26-2006 11:06 AM
Can't use public key authentication with SSH Noob69 Linux - General 5 01-06-2006 06:27 AM
SSH - Problem with Public Key Authentication HaPagan Linux - Security 5 11-28-2005 11:27 PM

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

All times are GMT -5. The time now is 02:07 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