Skip to content

Instantly share code, notes, and snippets.

@gauthamp10
Created September 29, 2021 18:07
Show Gist options
  • Select an option

  • Save gauthamp10/04fa17bf5625f34354bce6ecfc082ac6 to your computer and use it in GitHub Desktop.

Select an option

Save gauthamp10/04fa17bf5625f34354bce6ecfc082ac6 to your computer and use it in GitHub Desktop.
# Copying SSH Key From Root To Another User On Same Machine

Copying SSH Key From Root To Another User On Same Machine

    Create the folder if it doesn't already exist:

    mkdir /home/$USER/.ssh

    Make the directory only executable by the user:

    chmod 700 /home/$USER/.ssh

    Copy the authorized_keys file that contains your public key:

    sudo cp /root/.ssh/authorized_keys /home/$USER/.ssh/authorized_keys

    Make everything in .ssh owned by your user:

    sudo chown -R $USER:$USER /home/$USER/.ssh

    Make it readable only by your user:

    sudo chmod 600 /home/$USER/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment