SSH Keys

# If you haven't done so already, prepare your ~/.ssh/id_rsa.pub on your endpoint:
ssh-keygen
 
# Generate the command to type into the target:
echo -e "echo '$(cat $HOME/.ssh/id_rsa.pub)' >> ~/.ssh/authorized_keys"
 
# Absolute Path: /home/{USER}/.ssh/authorized_keys
# Absolute Path: /root/.ssh/authorized_keys
 
# Only if absolutly necessary: echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && service sshd restart
 
# If ~/.ssh/authorized_keys doesn’t exist on target:
mkdir ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chown -R {USER}:{USER} /home/{USER}/.ssh/
 
# Use the key
ssh -i ~/.ssh/id_rsa {RUSER}@{RHOST}

Relevant Note(s):