SSH Login Without Password | Drupal 8

SSH Login Without Password

Submitted by editor on Wed, 03/22/2017 - 23:26
Question

How to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id ?

Method 1:

#Generate SSH Private/Public key pair.
ssh-keygen
#Add public key to the server
ssh-copy-id -i ~/.ssh/id_rsa.pub name@domain.com
#If you have a message like : sign_and_send_pubkey: signing failed: agent refused operation, Add the key using:
ssh-add

Method 2: (Not tested)

#/!\ For the first time only
ssh-keygen -t rsa
#For all servers
ssh name@domain.com mkdir -p .ssh
cat ~/.ssh/id_rsa.pub | ssh name@domain.com 'cat >> .ssh/authorized_keys'
ssh name@domain.com "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

A Tip

# Optionally, you can add custom commands. Example : ll alias.
echo "alias ll='ls -alFh --color=auto'" >> ~/.bashrc;

Remove a key (On server)

  1. Login to the server
  2. Edit file .ssh/authorized_keys, Delete the unwanted key

Tags

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.