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:~$
-
3Please add more details as just pasting some code into a question doesn't at all help us help you at all– DavidOct 14, 2015 at 14:47
3 Answers
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.
-
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.– terdonOct 14, 2015 at 15:15
-
-
@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 theauthorized_keys
file won't be owned byhadoopuser
? Isn't it more likely there is simply no.ssh
directory?– terdonOct 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
-
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.
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"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