LinuxQuestions.org
Visit Jeremy's Blog.
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 08-22-2011, 12:46 PM   #1
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,561

Rep: Reputation: 37
ssh scp key not working to ssh/scp without password


I have Server1 and Server2, i want to be able to scp from Server1 to Server2 without being prompted for a password. Here's what I did. All of this is under the same username and password on both servers.

On Server1, I did a "ssh-keygen -t rsa", then copied the contents of id_rsa.pub.

On Server2, I vi'd the the .ssh/authorized_keys in that users home directory and pasted the info i just copied.

Now from Server1 when I do a "scp testfile username@Server2:/tmp" i still get prompted for a password.

On Server1 and Server2 the .ssh directory in that user's directory is 700 for permissions.

Any ideas?
 
Old 08-22-2011, 01:31 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Does this help?


Cheers,
Tink
 
Old 08-22-2011, 01:42 PM   #3
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,561

Original Poster
Rep: Reputation: 37
Hi Tink. the .ssh directories on both servers are 700, authorized_keys is 600 on target, and all the id_{dsa,rsa} I can find on both are 0600, and ~ is only writeable by that account.

Anything else i should check?
 
Old 08-22-2011, 01:56 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
sounds like you got everything.

can you share the tail section of 'ssh -vvv (destination ip)'
 
Old 08-22-2011, 02:12 PM   #5
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,561

Original Poster
Rep: Reputation: 37
i didnt even know you could do a -vvv. here's the output, i changed the username to protect myself with dumb questions

debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/UsernameRemoved/.ssh/identity
debug3: no such identity: /home/UsernameRemoved/.ssh/identity
debug1: Offering public key: /home/UsernameRemoved/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Offering public key: /home/UsernameRemoved/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
 
Old 08-22-2011, 02:19 PM   #6
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,561

Original Poster
Rep: Reputation: 37
wait, i figured it out!!! I looked in my authorized_keys on my destination, and realized when i copied and pasted from one putty session to another, it put line breaks in maybe because my putty windows were too small or something, once i removed the line breaks to have the phrase as one line with no spaces it worked. Thanks for that -vvv tip, that was cool!
 
Old 08-22-2011, 02:34 PM   #7
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
good job. thanks for updating us with the fix.
 
Old 08-22-2011, 02:44 PM   #8
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,561

Original Poster
Rep: Reputation: 37
luckily i had just read somewhere that the phrases could contain spaces or something, so it made me wonder. Hopefully my goof helps save someone down the road haha.
 
Old 08-22-2011, 05:03 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Ideally you'd want to use ssh-copy-id for that job rather
than copy & paste via terminal.

Last edited by Tinkster; 08-22-2011 at 05:11 PM.
 
Old 08-22-2011, 05:28 PM   #10
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,561

Original Poster
Rep: Reputation: 37
thanks, didnt know that command existed either, was just following some directions i found online to try it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Able to use scp and ssh without entering the password Drigo Linux - Newbie 4 07-21-2011 01:13 AM
Chroot SSH problem: ssh working, not SFTP & SCP. NaCo Linux - Security 3 02-01-2009 03:23 AM
SSH/SCP with no password wh33t Linux - Software 11 06-10-2007 12:38 AM
Ftp or SCP (ssh key) vladoportos Debian 2 02-20-2006 09:58 AM
ssh/scp without password not working Mauline Linux - Security 4 03-30-2005 10:26 PM


All times are GMT -5. The time now is 09:26 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration