Skip to main content

SSH login without password

SSH login without passwordYou want to use Linux and OpenSSH to automate your tasks. Therefore
you need an automatic login from host A / user a to Host B / user b.
You don't want to enter any passwords, because you want to call ssh
from a within a shell script.

How to do it

First log in on A as user a and generate a pair of authentication keys.
Do not enter a passphrase:

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):

a@A:~> ssh b@B mkdir -p .ssh
b@B's password: 
Finally append a's new public key to b@B:.ssh/authorized_keys and
enter b's password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password: 
From now on you can log into B as b from A as a without password:

a@A:~> ssh b@B
A note from one of our readers:
Depending on your version of SSH you might also have to do the
following changes:


  • Put the public key in .ssh/authorized_keys2
  • Change the permissions of .ssh to 700
  • Change the permissions of .ssh/authorized_keys2 to 640
Keywords:
ssh
openssh
password
  Author: Mathias Kettner

Check_MK 
MK
http://www.linuxproblem.org/art_9.html

Comments

Popular posts from this blog

Kivandanu, Could one of our premium services help you?

http://srudut.com 2011/2/22 John Dalt < John@galtstock.com > You are receiving this message, because you have subscribed to the newslettera1 newsletter on Monday, January 17th, 2011. To ensure that you continue to receive emails from us, add John@galtstock.com to your address book promptly.         Galtstock       Research for Online Investors HOME       ARCHIVE     NEWS      RESOURCES       DIVERSIONS Monday Morning The market set a new 52-week high Friday...where does it end?  Today reports out of Libya don't sound promising.  Protesters have burned the General Assembly building.  BP is evacuating their personnel. Guddafi is reported to be heading to Venezuela. There were also reports yesterday of protests in China.  The police quickly arrested any suspicious actors.  Suffice it to say, this is not a market you can buy and forget.   There are plenty of moving pieces to keep track of...problems and opportuni

Download Qari/Reciters and Translations, Al-Quran ReadPen Data

  Al-Quran ReadPen Data Download Qori/Reciters and Translations   Qori/Reciter Files Sr. Qori/Reciter Name File Size Updates 01. Al Sheikh Ali Abdul Rahman Al Huzaifi 222 MB 17 Mar 2012 02. Al Sheikh Abdul Basit 'Abd us-Samad 387 MB 19 Mar 2012 03. Al Sheikh Mishary bin Rashid Al-Afasy 228 MB 13 Mar 2012 04. Al Sheikh Ahmad Ali Mohammad ‘al Soulayman Al Ajamy 212 MB 17 Mar 2012 05. Al Sheikh Salaah bin Muhammad Al Budair 164 MB 17 Mar 2012 06. Al Sheikh Mohammed Al-Alim Al-Dokhail 417 MB 07 Oct 2011 07. Al Sheikh Sa’ad Al-Ghamdi 201 MB 13 Mar 2012 08. Al Sheikh Mahmoud Khal