SSH login without password

Your aim

You want to use Linux and OpenSSH to automize 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 hostname
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

   

SSH login without password的更多相关文章

  1. 3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id

    http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-s ...

  2. 【转载】SSH login without password 免密登陆

    Your aim You want to use Linux and OpenSSH to automate your tasks. Therefore you need an automatic l ...

  3. Fixing ssh login long delay

    原文:http://injustfiveminutes.com/2013/03/13/fixing-ssh-login-long-delay/ For a long time I had a prob ...

  4. 无法连接 MKS: Login(username/password)incorrect

    升级到Vmware Workstation 12之后,客户端能连上虚拟机服务器,但却打不开共享的虚拟机,提示报错"无法连接 MKS: Login(username/password)inco ...

  5. 实现ssh的无password登录

    这里所说的ssh是指OpenSSH SSHclient.是用于登录远程主机.而且在远程主机上运行命令.它的目的是替换rlogin和rsh,同一时候在不安全的网络之上,两个互不信任的主机之间,提供加密的 ...

  6. Passwordless SSH Login

    原文地址:http://manjeetdahiya.com/2011/03/03/passwordless-ssh-login/ Consider two machines A and B. We w ...

  7. Security configuration of SSH login entry - enterprise security practice

    catalog . 引言 . 修改ssh端口 . 禁用root远程ssh登录 . 只使用SSH v2 . 限制用户的SSH访问 . 禁用.rhosts文件 . 禁用基于主机的身份验证 . 基于公私钥的 ...

  8. ssh 设置免password登录

    如果: 实现->操作机A机 要以用户"user1"身份.免password登录B机和C机? B机和C机 建立用户 user1 而且能够ssh 登录. A机设置: 1.安装ss ...

  9. ssh login nova vm

    $ sudo cat >> /usr/bin/nova-ssh  << END FIRST=$1 IDX=`expr index $1 "@"`if [[ ...

随机推荐

  1. Linux 中 MySQL 授权远程连接

    说明:当别的机子(IP )通过客户端的方式在没有授权的情况下是无法连接 MySQL 数据库的,如果需要远程连接 Linux 系统上的 MySQL 时,必须为其 IP 和具体用户进行授权.一般 root ...

  2. linux下mysql常用的基本命令

    linux数据库环境搭建好之后,我们就可以创建数据库了.   一 查看版本 mysql --version 二 进入数据库 首先在根目录执行命令 mysql -u root -p   然后输入密码 进 ...

  3. Django REST framework 五种增删改查方法

    Django-DRF-视图的演变   版本一(基于类视图APIView类) views.py: APIView是继承的Django View视图的. 1 from .serializers impor ...

  4. 爬虫练习四:爬取b站番剧字幕

    由于个人经常在空闲时间在b站看些小视频欢乐一下,这次就想到了爬取b站视频的弹幕. 这里就以番剧<我的妹妹不可能那么可爱>第一季为例,抓取这一番剧每一话对应的弹幕. 1. 分析页面 这部番剧 ...

  5. Hive 导入数据报错,驱动版本过低

    Failed with exception Unable to alter table. javax.jdo.JDODataStoreException: You have an error in y ...

  6. 16,re模块的常用方法

    ret =re.findall('\d+', 'eva123egon4yuan567') print(ret)#返回满足条件的结果 ,放在一个列表里. ret2 = re.search('\d+',' ...

  7. Exchange 正版化 授权

    网友说法: Exchange服务器版其实价格不高,企业版也就是几万左右,贵的是客户端授权,一个客户端授权大概要300多.但是,但是,中国企业买Exchange客户端一般都是可以按比例买的,比如10%- ...

  8. joyoi1957 「Poetize5」Vani和Cl2捉迷藏

    最小路径可重点覆盖.先传递闭包,然后拆点,\(n-\)最大匹配,看算法竞赛进阶指南. #include <iostream> #include <cstring> #inclu ...

  9. lfyzoj104 Counting Swaps

    问题描述 给定你一个 \(1 \sim n\) 的排列 \(\{p_i\}\),可进行若干次操作,每次选择两个整数 \(x,y\),交换 \(p_x,p_y\). 请你告诉穰子,用最少的操作次数将给定 ...

  10. android 之 GridView

    GridView 的用法基本与ListView类似. 程序布局文件main.xml <?xml version="1.0" encoding="utf-8" ...