LinuxQuestions.org
Review your favorite Linux distribution.
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 08-22-2011, 11:46 AM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
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, 12:31 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Does this help?


Cheers,
Tink
 
Old 08-22-2011, 12:42 PM   #3
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
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, 12:56 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

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

can you share the tail section of 'ssh -vvv (destination ip)'
 
Old 08-22-2011, 01:12 PM   #5
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
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, 01:19 PM   #6
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
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, 01:34 PM   #7
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
good job. thanks for updating us with the fix.
 
Old 08-22-2011, 01:44 PM   #8
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
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, 04:03 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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 04:11 PM.
 
Old 08-22-2011, 04:28 PM   #10
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

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


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

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

All times are GMT -5. The time now is 01:52 PM.

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