I'm working as user "papagolf" which is a sudo user. I created a new group "hadoop" by using
papagolf@Sierra:~$ sudo addgroup hadoop
Created a user "haduser"
papagolf@Sierra:~$ sudo adduser --ingroup hadoop haduser
I've already created ssh keys in papagolf's .ssh directory and copied the public key file into this new directory
papagolf@Sierra:~$ cp hadoop_keys.pub /home/haduser/.ssh/
Created a new file in .ssh/authorized_keys
papagolf@Sierra:~$ cd /home/haduser/.ssh/ papagolf@Sierra:/home/haduser/.ssh$ sudo touch authorized_keys
Now I wanted to copy the content of .pub file to authorized_keys but I got an error saying that the permission is denied. I wonder why it happened even when I'm a sudo user.
papagolf@Sierra:/home/haduser/.ssh$ sudo cat hadoop_keys.pub >> authorized_keys bash: authorized_keys: Permission denied
Now I tried this and it was successful
papagolf@Sierra:/home/haduser/.ssh$ sudo -i root@Sierra:/home/haduser/.ssh# cat hadoop_keys.pub >> authorized_keys
What's the difference? Why did the error occur?