Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

SSH Login Without Password

By editor , 22 March, 2017
Question

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

Method 1:

#Generate SSH Private/Public key pair.
ssh-keygen
# OR : ssh-keygen -t rsa -b 2048 -C "email@example.com"
#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;

 

If : "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!"

ssh-keygen -f ~/.ssh/known_hosts -R "name@domain.com"

 

 

Remove a key (On server)

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

 

NOTE : Permission

If the .ssh/id_rsa file hasn't correct permission you can't login, set permission to 0700

NOTE : Usage on Windows

This method is working for the cli on Windows like CygWin, Git Bash ... (Not tested on windows command prompt, putty ...)

Tags

  • Server
  • Linux
SSH Renew / Remove remote host identification.
Notify When SSH connection success

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer