Skip to content

Instantly share code, notes, and snippets.

@mansouryaacoubi
Created January 30, 2019 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mansouryaacoubi/ad8a840eb815ef376eeaae41336d34e7 to your computer and use it in GitHub Desktop.
Save mansouryaacoubi/ad8a840eb815ef376eeaae41336d34e7 to your computer and use it in GitHub Desktop.
Login into server via ssh without server

First create private-public key pairs

ssh-keygen -t rsa

Then create .ssh directory on remote computer

ssh user@remote.com mkdir -p .ssh

Add public key to authorized keys

cat .ssh/id_rsa.pub | ssh user@remote.com 'cat >> .ssh/authorized_keys'

Create .ssh/config file and add host

nano ~/.ssh/config
Host remoteserver
    User user
    HostName remote.com
    IdentityFile ~/.ssh/id_rsa
    Port 22

Login without password

ssh remoteserver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment