Skip to content

Instantly share code, notes, and snippets.

@JinhaiZ
Created December 8, 2017 10:02
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 JinhaiZ/cfef8536b2cedb4491bcffc991049363 to your computer and use it in GitHub Desktop.
Save JinhaiZ/cfef8536b2cedb4491bcffc991049363 to your computer and use it in GitHub Desktop.
Configuration SSH connection between client and server

Server side

  1. install ssh server

    sudo apt-get install openssh-server
    

Client side

  1. generate a key pair

    ssh-keygen -t rsa
    

    if your have entered file in which to save the key, for example, flir then two file named flir and flir.pub will be generated at the current folder, represent private key and public key respectively. If not, rsa and rsa.pub is the name by default, and they can be found at the folder ~/.ssh/

  2. the private key and public key should be palced at $HOME/.ssh/

    mv flir ~/.ssh/
    mv flir.pub ~/.ssh/
    
  3. uplode the public key flir.pub to the server

    ssh-copy-id -i ~/.ssh/flir.pub <username>@<ipaddress>
    
  4. now try logging into the server with ssh <username>@<ipaddress>

In a nutshell

  • The client generate a private key and public key pair
  • The private key should be placed at the folder ~/.ssh/ of client
  • The content of public key should be concatenated at the file ~/.ssh/authorized_keys of server
  • The ~/.ssh folder should be in mode drwx------ (700) in order to forbidden to other users
  • Once configured the ssh login with key, it's better to refuse access by password at the server side by setting PasswordAuthentication no in /etc/ssh/sshd_config of the server

Reference

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