How to create .ssh directory on Linux system using command line

Do we have some sort of rule for creating $HOME/.ssh/ directory for any user on Linux? I need to create an empty dir for /root/.ssh/. How do I create .ssh directory on Linux with security in mind?

You run the following commands:

mkdir -p $HOME/.ssh
chmod 0700 $HOME/.ssh
chown user:user $HOME/.ssh
## if user is root ## 
chown -R root:root $HOME/.ssh

That is all. For more info see:


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki