Skip to content

Instantly share code, notes, and snippets.

@M0r13n
Created July 9, 2020 09:29
Show Gist options
  • Save M0r13n/1167a3f498156ca3e67d5a4fec9f6ebc to your computer and use it in GitHub Desktop.
Save M0r13n/1167a3f498156ca3e67d5a4fec9f6ebc to your computer and use it in GitHub Desktop.
Quick way to enable SSH authentication via keyfile.

Quick way to setup SSH via keyfile

On the remote host:

ssh-keygen -t rsa -b 2048

The key location is /root/.ssh/id_rsa.

Public key can be found in /root/.ssh/id_rsa.pub. Private key can be found in /root/.ssh/id_rsa.

NOTE: Permission of private key should be 0600.

On local host:

ssh-copy-id USER@HOST-IP

Note: You might need to execute : install openssh-clients.

Restrict password-based login:

Edit sshd_config file:

sudo nano /etc/ssh/sshd_config

and add PermitRootLogin without-password.

Finally execute: service sshd reload.

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