Hi I tried to create a folder for ssh key in root with this command:
mkdir /root/.ssh && chown -R root:root /root && chmod -R 770 /root
and I have permission denied:
mkdir: cannot create directory ‘/root/.ssh’: Permission denied
Hi I tried to create a folder for ssh key in root with this command:
mkdir /root/.ssh && chown -R root:root /root && chmod -R 770 /root
and I have permission denied:
mkdir: cannot create directory ‘/root/.ssh’: Permission denied
The super user has no real reason to have SSH access. It's is safer to set up an ordinary user with SSH access to the machine and then use sudo when needed. You can even set PermitRootLogin no in your sshd_config file (under /etc somewhere) unless you, for some reason, think you may need to actually log in as root to unbreak the system at some point (which you can do from the console anyway, if you have physical access to the machine).
Having said that, you are probably executing your commands as an ordinary user which is why you don't have permission to perform the operations.
Never change ownership or permissions on the /root directory though. They are correctly set up from the start and shouldn't need changing (which may open up for security holes later).
On all the systems I've set up, the original contents of /root and the directory itself is totally untouched. Nothing added, nothing taken away, nothing modified. The root account is special, and you should rarely, if ever, see an interactive root prompt.
You have to switch the user to root "#su root" OR you can use the below command with sudo prefix sudo mkdir /root/.ssh && chown -R root:root /root && chmod -R 770 /root
Note: your local must be added in sudoers file.