otmfaqForumsBlogsRegister
FAQMembers ListCalendarToday's PostsSearch


 Subscribe Blogs:RSS
 Subscribe Forums:RSS
OTMFAQ Home
OTMFAQ Blogs
OTMFAQ Forums
OTMFAQ Tutorials

OTM SIG
MavenWire


SysAdmin and Management Managing and monitoring OTM / G-Log and other administrative activities.

Tags: , ,

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old May 24th, 2006, 01:01
chrisplough's Avatar
Site Moderator
 
Join Date: Jun 2006
Location: West Chester, PA
Posts: 847
Blog Entries: 7
Thanks: 53
Thanked 205 Times in 124 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Rep Power: 10
chrisplough has a spectacular aura aboutchrisplough has a spectacular aura aboutchrisplough has a spectacular aura about
Send a message via AIM to chrisplough
[SOLVED] Using ssh keys for no-password logins

I was helping a client setup ssh with public/private keys between two servers, so that they could use ssh, scp and sftp without having to enter passwords. This was primarily so that they could script a secure file transfer between the two servers. below are the steps taken to set everything up.

Note: the usernames and passwords have been changed, to ensure the systems remain secure. I've provided dummy keys below for reference.

First, we need to login to the client machine (the one that starts the ssh/scp/sftp connections) and create an ssh key pair. When it prompts for a password for the key, just press enter (don't enter one). While this does reduce the security of the implementation, it ensure that automated processes don't need passwords when connecting from client to server.

Code:
freddy:~ cwplough$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/cwplough/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/cwplough/.ssh/id_dsa.
Your public key has been saved in /home/cwplough/.ssh/id_dsa.pub.
The key fingerprint is:
23:30:5d:45:c5:37:27:38:7e:66:2a:46:59:15:3a:f8 cwplough@freddy.mavenwire.com
Next, we'll take a quick look at the ssh public key, just to see what it contains.

Code:
freddy:~ cwplough$ cd .ssh
freddy:~/.ssh cwplough$ more id_dsa.pub
ssh-dss AAAsd3NzaC1kc3MAAACBAMTf2OqoiHQ3kJlYp2mxr7fAYQ6VdkOVTR0G3lEgXQItJ/sRA478djd938V0FtjCyZ9jIFb0GBXJnUa+rWU1moQWciMwc7cHuWh3Iana4CuDBG1oCUEAgdg10t7EKse3OMLBk+4hGQVIgfkdkd+seGtYb62kRZsJMN/RGAJBta49JAAAAFQCN72UA0+ms1Tn7aqtfxTwYUts0twAAAIEAki82UN5KS5sKOmhagEwjVBbHGVjJb/badkldkdvmTVyCHWOxbmIWy8XyWguBZlowqjz5wibIM6N4Fj4XI7Z3zuXCXnEpvvlYeS4fpBzwGZ7pUA83qXxh3QZ0YP+NvSv8Xe7jw2+Kq7KVtgK0UN1dEuBtUl2Tbwr9jFLoAzbi6DgIAAACBAJ3gBqdFoCJ1KCo/jjkGzrkvp4N1B0qVGh2u7D0DtZqhAhULHEfmUdjdjQ4ZfnNsD2ZKvjFVMzZQQsKMFXD98mXJ5qvS8lPJ6KcZHfZdpp4y5iWAg/WqnU8HbroQKN9vt/HJ6xqQ5hATCrNYvswNgcWfS9wsdfsdfssdU9FPkJxaT cwplough@freddy.mavenwire.com
Once we've verified that it exists, we can copy it over to the server(s) that we want to login to without passwords.

Code:
freddy:~/.ssh cwplough$ scp id_dsa.pub cwplough@ginger.mavenwire.com:~/
Next, login to the server, so that we can put the ssh key into place.

Code:
cwplough@ginger [~]# mkdir .ssh   #if the directory already exists, you can skip this step.
cwplough@ginger [~]# cat id_dsa.pub >> .ssh/authorized_keys
cwplough@ginger [~]# cd .ssh
cwplough@ginger [~/.ssh]# ln -s authorized_keys authorized_keys2
Next, ensure the permissions of the authorized_keys* files are 644 - if they are more relaxed than this, OpenSSH will notice and you'll continue to get prompted for a password.

Code:
cwplough@ginger [~/.ssh]# chmod 644 authorized_keys*
I like to verify the contents of the authorized_keys file, just in case

Code:
cwplough@ginger [~/.ssh]# cat authorized_keys
ssh-dss AAAsd3NzaC1kc3MAAACBAMTf2OqoiHQ3kJlYp2mxr7fAYQ6VdkOVTR0G3lEgXQItJ/sRA478djd938V0FtjCyZ9jIFb0GBXJnUa+rWU1moQWciMwc7cHuWh3Iana4CuDBG1oCUEAgdg10t7EKse3OMLBk+4hGQVIgfkdkd+seGtYb62kRZsJMN/RGAJBta49JAAAAFQCN72UA0+ms1Tn7aqtfxTwYUts0twAAAIEAki82UN5KS5sKOmhagEwjVBbHGVjJb/badkldkdvmTVyCHWOxbmIWy8XyWguBZlowqjz5wibIM6N4Fj4XI7Z3zuXCXnEpvvlYeS4fpBzwGZ7pUA83qXxh3QZ0YP+NvSv8Xe7jw2+Kq7KVtgK0UN1dEuBtUl2Tbwr9jFLoAzbi6DgIAAACBAJ3gBqdFoCJ1KCo/jjkGzrkvp4N1B0qVGh2u7D0DtZqhAhULHEfmUdjdjQ4ZfnNsD2ZKvjFVMzZQQsKMFXD98mXJ5qvS8lPJ6KcZHfZdpp4y5iWAg/WqnU8HbroQKN9vt/HJ6xqQ5hATCrNYvswNgcWfS9wsdfsdfssdU9FPkJxaT cwplough@freddy.mavenwire.com
Now, log back into the client machine and test it!

Code:
freddy:~ cwplough$ sftp cwplough@ginger.mavenwire.com
sftp>
From this point on, you can ssh, scp and sftp into the server without a password.
__________________
Chris Plough
MavenWire

www.MavenWire.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread



Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Impact of changing the glogowner password bluesdude SysAdmin and Management 3 December 11th, 2007 03:29
[SOLVED] Issue: Changing GUEST.ADMIN Password Causes OTM Restart to Fail chrisplough Security 0 June 12th, 2007 03:53
[SOLVED] Securing WebLogic - Hiding the system Password chrisplough Security 0 October 3rd, 2006 15:27



All times are GMT. The time now is 22:36.
Copyright © 2008, Open Book Solutions LLC. All rights reserved.

Sponsored by MavenWire - MavenWire.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37