Skip to content

Instantly share code, notes, and snippets.

@tayhimself
Last active June 6, 2017 19:52
Show Gist options
  • Save tayhimself/79dc3201958155782cd806c094de6828 to your computer and use it in GitHub Desktop.
Save tayhimself/79dc3201958155782cd806c094de6828 to your computer and use it in GitHub Desktop.
# On the local machine the command below creates a public key in .ssh/id_rsa.pub
ssh-keygen -t rsa
# Copy this to the remote server
scp .ssh/id_rsa.pub user@remote-ip:/home/tayhimself/.
# ssh in to the remote server and cd into the home dir
cat id_rsa.pub >> .ssh/authorized_keys
# OR
# do it in 1 step
cat ~/.ssh/id_dsa.pub | ssh yourremotelogin@sshserver 'cat >> .ssh/authorized_keys'
#delete the pub key
shred -u id_rsa.pub
#You can copy the config file to change user and give the remote server a shortcut name
# In your .ssh/config on the local machine
Host backup
HostName 10.0.0.1 #your backup server
User root
# now you can type ssh backup and you'll be all set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment