Skip to content

Instantly share code, notes, and snippets.

@vutranvn
Last active October 7, 2017 15:59
Show Gist options
  • Save vutranvn/07f890daa7d1f19dfcc38728bbb5628f to your computer and use it in GitHub Desktop.
Save vutranvn/07f890daa7d1f19dfcc38728bbb5628f to your computer and use it in GitHub Desktop.
** Client Machine **
- Create ssh key
> ssh-keygen -t rsa
- Key is saved default at ~/.ssh/id_rsa
- Enter passphrase
- Copy public key ~/.ssh/id_rsa.pub
> pbcopy < ~/.ssh/id_rsa.pub OR cat ~/.ssh/id_rsa.pub
** Server **
- Create directory .ssh
> mkdir -p ~/.ssh
- Paste public key to file ~/.ssh/authorized_keys
> chmod 700 -R ~/.ssh
> chmod 600 ~/.ssh/authorized_keys
- Turn off password
> nano /etc/ssh/sshd_config
- Find and setting
PasswordAuthentication no
UsePAM no
> systemctl reload ssh
NOTE: SSH Key doesn't working if SELinux ON. To disable SELinux:
> nano /etc/selinux/config
- Find and Replace SELINUX=enforcing to SELINUX=disabled
- Reboot server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment