Sandeep vashisth
Sandeep vashisth

Reputation: 1098

could not create directory /home/hadoop/.ssh : permission denied?

I am configuring hadoop on Ubuntu os. I need to create RSA key pair to allow hadoop to interact with its nodes, so i running this command:

hadoop@ubuntu:~$ ssh-keygen -t rsa -P ""

then I get this:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):
Could not create directory '/home/hadoop/.ssh': permission denied.
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
open /home/hadoop/.ssh/id_rsa failed: No such file or directory.
Saving the key failed: /home/hadoop/.ssh/id_rsa.

Upvotes: 1

Views: 23218

Answers (4)

alok
alok

Reputation: 2756

I have spent arround 1 hr on this and finally got the solution. It is due to permission problem. You have to use chown for your 'hadoop user'.

1. First make hadoop directory.
cd /home 
mkdir hadoop
then check 'ls -l'. it gives result like :
drwxr-xr-x  2 hadoop hadoop 4096 Aug 22 22:17 hadoop

2. sudo chown hadoop.hadoop /home/hadoop/
3. Then run remaining command for key generater.

Upvotes: 0

Vamshi
Vamshi

Reputation: 1

Seems like current user doesn't own the contents under home directory.

Gain the ownership as shown as below:

admin@mydb22-02:~$ sudo chown admin.admin /home/admin/
admin@mydb22-02:~$ ls -la
total 32
drwxr-xr-x 2 admin admin 4096 Nov  3 23:29 .
drwxr-xr-x 3 admin admin 4096 Dec 23  2012 ..
-rw------- 1 admin admin  191 Feb 13  2013 .bash_history
-rw-r--r-- 1 admin admin  220 Apr  3  2012 .bash_logout
-rw-r--r-- 1 admin admin 3486 Apr  3  2012 .bashrc
-rw-r--r-- 1 admin admin  675 Apr  3  2012 .profile
-rw-r--r-- 1 admin admin    0 Nov  3 23:29 .sudo_as_admin_successful
-rw------- 1 admin admin 4221 Nov  3 20:31 .viminfo

generating keys would work now as .ssh directory will now be created and owned by current user after generating the assymetric keys

Upvotes: 0

Jalal Hajigholamali
Jalal Hajigholamali

Reputation: 379

check your home directory name and permissions

             echo $HOME
             cd ~ ; ls -l 
             ls -l .ssh
             ls -lR .ssh

if above output is OK and you have correct permissions, perhaps your quota is full

try with "sudo" and see what happens...

Upvotes: 1

loentar
loentar

Reputation: 5249

Forgot to create .ssh dir in your home?

Try that:

mkdir -p ~/.ssh

then re-run ssh-keygen.

Also possibly you doing ssh-keys creation from wrong user.. You started that shell using sudo?

Try to set HOME dir manually or enter right path in prompt.

Upvotes: 6

Related Questions