LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
Search this Thread
Old 03-21-2013, 10:17 PM   #1
aztroboy
LQ Newbie
 
Registered: Jun 2010
Posts: 19

Rep: Reputation: 0
How to ssh into localhost? (permission denied publickey)


Greetings,

I have searched for a solution to this problem with no luck:

I am trying to install hadoop on my Ubuntu machine. For that to happen, I need to setup keys so that the localhost can ssh into the same machine (inception?)

I currently ssh into the machine without needing to use a passphrase.

I have setup new keys so that hadoop can work on the same machine. I used the following commands:

Code:
sudo ssh-keygen -t dsa
sudo cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
all files in /.ssh folder have an 600 chmod permission

however, if I try to ssh into localhost it prompts:

Code:
Permission denied (publickey).
if I run sudo ssh localhost -v, the last lines are:

Code:
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Offering DSA public key: /root/.ssh/id_dsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).
I have to mention that I have created several keys and erased some others in the authorized_key file, leaving only the one that lets me ssh into the machine.

I would like to know how to get rid of this Permission denied (publickey) error.

Last edited by aztroboy; 03-21-2013 at 10:43 PM.
 
Old 03-21-2013, 10:21 PM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 808
Blog Entries: 2

Rep: Reputation: 203Reputation: 203Reputation: 203
Why did you generate RSA but then add DSA to the authorized_keys ?
 
Old 03-21-2013, 10:25 PM   #3
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,434

Rep: Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192
Hi,

you can check /var/log/auth.log to see the output from the ssh server: it might provide some useful information as to what is going on. You can also get more information on the client side by adding a few more v's. Eg
Code:
ssh -vvvv localhost
BTW, why are you using sudo to generate the key? Generally you shouldn't ssh to anywheere as root, and very often (always no the machines I administer) root ssh logins are disabled in /etc/ssh/sshd_config wit hthe line:
Code:
PermitRootLogin no
Evo2.
 
Old 03-21-2013, 10:30 PM   #4
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 808
Blog Entries: 2

Rep: Reputation: 203Reputation: 203Reputation: 203
You've also been doing funny things with sudo. Can you show us what you get from
Code:
sudo -l
(interested in always_set_home) ?

This will create a pair of files owned by root (if they don't already exist) either under ~root or in the CWD.
Code:
sudo ssh-keygen -t rsa
This will attempt
Code:
sudo cat
with two files related to the home directory of the current user.
Code:
sudo cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
 
Old 03-21-2013, 10:46 PM   #5
aztroboy
LQ Newbie
 
Registered: Jun 2010
Posts: 19

Original Poster
Rep: Reputation: 0
Sorry I just edited the command. I used dsa all the time on all the commands

I used:

sudo ssh-keygen -t dsa
sudo cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys


Quote:
Originally Posted by linosaurusroot View Post
You've also been doing funny things with sudo. Can you show us what you get from
Code:
sudo -l
(interested in always_set_home) ?

This will create a pair of files owned by root (if they don't already exist) either under ~root or in the CWD.
Code:
sudo ssh-keygen -t rsa
This will attempt
Code:
sudo cat
with two files related to the home directory of the current user.
Code:
sudo cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
it prompts the following:

Code:
Matching Defaults entries for ubuntu on this host:
    env_reset,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User ubuntu may run the following commands on this host:
    (ALL) ALL
    (ALL) NOPASSWD: ALL
BTW my current user is ubuntu, not root. In this case, what should I do?
(relevant: I'm ssh-ing from my PC to a remote PC and we don't need passphrases (already set keys for both machines), now I'm trying to make the remote PC to ssh into localhost without luck. I have to use the user ubuntu. Maybe I should give him root priviledges?)

BTW the PermitRootLogin is set to yes

Last edited by aztroboy; 03-21-2013 at 10:51 PM.
 
Old 03-22-2013, 07:56 AM   #6
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 808
Blog Entries: 2

Rep: Reputation: 203Reputation: 203Reputation: 203
I agree you should be looking at logs (such as /var/log/auth.log) to get more info on this.

If you're intending hadoop to work as the "ubuntu" user do all your ssh setup as "ubuntu" without using sudo. If you're intending hadoop to work as root then work from a root shell without using sudo on each command.
 
Old 03-23-2013, 07:29 PM   #7
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,434

Rep: Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192
Hi,

if you are using the user "ubuntu", then please stop doing things with sudo. Forget about sudo and root. Repeat the key generation and copying to authorized_keys as the user "ubuntu". Then try to "ssh -vvv localhost" again: check the output, read /var/log/auth.log etc.

Evo2.
 
  


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
SSH: Permission denied (publickey). clapclash Linux - Networking 6 10-19-2012 06:49 AM
[SOLVED] ssh killing me :( Permission denied (publickey) grail Linux - Newbie 10 07-06-2010 10:47 AM
[SOLVED] SSH - Permission denied (publickey,keyboard-interactive) sarves Linux - Newbie 3 05-12-2010 12:55 AM
ssh client say me Permission denied.(publickey). linderox Linux - Networking 2 02-27-2008 09:36 AM


All times are GMT -5. The time now is 05:00 AM.

Main Menu
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