0
dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/.ssh/authorized_keys
bash: /home/hadoopuser/.ssh/authorized_keys: No such file or directory
dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/ .ssh/authorized_keys
bash: /home/hadoopuser/: Is a directory
dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/ .ssh/authorized_keys/
bash: /home/hadoopuser/: Is a directory
dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/.ssh/authorized_keys
bash: /home/hadoopuser/.ssh/authorized_keys: No such file or directory
dhruvhadoop1@hadoopmaster:~$ 
1
  • 3
    Please add more details as just pasting some code into a question doesn't at all help us help you at all
    – David
    Oct 14, 2015 at 14:47

3 Answers 3

1

The .ssh directory and it's files have strict access permissions: The files are only readable/writable by the owner (or root). If you are not hadoopuser, then you'll have to:

sudo sh -c 'cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/.ssh/authorized_keys'

The error message is a bit misleading. You're trying to append, so the shell has to check if the authorized_keys file exists. You don't have read permission on the .ssh directory, so the shell cannot complete that check.

5
  • What makes you think the OP is not the hadoop user? That should produce a "permission denied", right? Also, won't what you are suggesting break the ssh authentication since the files will not belong to the hadoop user? I get the expected "permission denied" error on my system.
    – terdon
    Oct 14, 2015 at 15:15
  • Mostly, his prompt. Oct 14, 2015 at 15:17
  • @glennjackman ah, good point, I missed that. Still, I tried a similar thing on my system and got a permission denied error. What would result in the "no such file" error? Also, doesn't this break ssh since the authorized_keys file won't be owned by hadoopuser? Isn't it more likely there is simply no .ssh directory?
    – terdon
    Oct 14, 2015 at 15:36
  • I'm also getting permission denied. Let's see if @Dhruv supplies any further information Oct 14, 2015 at 16:50
  • nevermind, he posted a duplicate question. Oct 14, 2015 at 16:51
1

The .ssh folder are not exist because you haven't created any key yet. you must first create your key like this:

ssh-keygen 

and enter any question that shell asked. after this you have .ssh folder in your home.

-2

Most of the error messages you posted are because you are not using the correct path as you have added a space in various locations or specified a directory rather then a file.

The only error message of any real relevance is

/home/hadoopuser/.ssh/authorized_keys: No such file or directory

You can not append a non-existant file so either copy the file (preferred method)

cp /home/hadoopuser/.ssh/id_rsa.pub /home/hadoopuser/.ssh/authorized_keys

or create the file with a single >

cat /home/hadoopuser/.ssh/id_rsa.pub > /home/hadoopuser/.ssh/authorized_keys
1
  • 1
    "You can not append a non-existant file" -- wrong. The >> redirection will create the file if it does not exist. Oct 14, 2015 at 15:02

Not the answer you're looking for? Browse other questions tagged .