LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-20-2008, 05:19 AM   #1
Elguapo
Member
 
Registered: Mar 2005
Distribution: FC7
Posts: 42

Rep: Reputation: 15
Setting up authorized keys


I am working on a little project and I am trying to figure out how to setup authorized keys. So that myself or anyone else working on the project does not need to enter a password every time they need to log in.

So far all the results I ahve received have failed.

This is what I have done so far.

Code:
mkdir .ssh
chown soltiss .ssh/
ssh-keygen -t rsa
Enter file in which to save the key (/root/.ssh/id_rsa): /home/soltiss/.ssh/id_rsa
Enter passphrase (empty for no passphrase): <entered pass phrase>
Enter same passphrase again: <entered pass phrase>
Your identification has been saved in /home/soltiss/.ssh/id_rsa.
Your public key has been saved in /home/soltiss/.ssh/id_rsa.pub.

touch authorized_keys2
chmod 600 authorized_keys2
cat id_rsa.pub >> authorized_keys2
cp authorized_keys2 ~/.ssh
To add a bit more information, what I have done after the keys has been generated is, I take the private key and use PuttyGen to create a ppk file. So that I can use putty to login to the machine. However, every time I try to log into the machine I am asked for a password. The whole point of setting up the authorized keys is so that when using my svn we don't need to input a password each time we want to commit/update.

This is the output from ssh with verbose
Code:
ssh -v soltiss@<ipaddress>
OpenSSH_4.5p1, OpenSSL 0.9.8b 04 May 2006
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to <ipaddress> [<ipaddress>] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.5
debug1: match: OpenSSH_4.5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.5
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '<ipaddress>' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found

debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found

debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found

debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
soltiss@<ipaddress>'s password:
 
Old 09-20-2008, 05:42 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Did you read http://the.earth.li/~sgtatham/putty/...ubkey-puttygen
 
Old 09-20-2008, 07:00 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can just hit enter when creating your key and it asks for a passphrase. This isn't as secure. If anyone can read your private key or the .ppk file then they can gain access. The passphrase protects the client's private key.

A compromise in Linux is to use ssh-agent and ssh-add. This will allow you to enter the passphrase once in a session and not need to enter it again. You would use it like:
Code:
eval $(ssh-agent)
ssh-add
At this point you will be asked for the keyphrase. Now you can log in to the serer with ssh or use scp or sftp without needing the passphrase again.

The reason for using public key authentication is to be able to disable password authentication at the server. This will eliminate most attacks against ssh.

If you don't mind putting your server at risk, you could rerun ssh-keygen. "ssh-keygen -p -f /home/soltiss/.ssh/id_rsa". You will be prompted for the old passphrase. Next you will be prompted for the new one. Simply press enter to have a null passphrase.

You also need to configure /etc/ssh/sshd_config at the server to use public key authentiation.
Here are the non-blank or commented lines from my file. The instructions are given in the config file just above the "UsePam Yes" line.
Code:
Protocol 2
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
Subsystem       sftp    /usr/lib64/ssh/sftp-server
AllowUsers jschiwal@hpamd64.jesnet jschiwal@qosmio.jesnet
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL

Last edited by jschiwal; 09-20-2008 at 07:36 AM.
 
Old 09-20-2008, 07:37 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
If you're executing those commands as root, then cp authorized_keys2 ~/.ssh will place the .ssh/authorized_keys2 file in roots home and not soltiss's. Why not generate and set up the keys as the user they're intended for?
 
  


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
Help setting up SSH keys Atif Khan Linux - Newbie 2 07-10-2008 05:37 AM
Setting keys anitha.mit Linux - Newbie 3 01-04-2008 05:57 PM
KGpg setting for importing public keys linuxbeliever Debian 2 06-12-2007 12:17 PM
Setting keys on keyboard using xmodmap aoberoi Ubuntu 7 06-18-2006 01:50 AM
Problem setting up multimedia keys in Gnome 2.6 Phantomas Linux - Software 7 06-07-2004 01:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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