目前很多服务(ceph,openstack等)都需要用到SSH使用ssh-key进行登录,而不能使用密码进行登录。

下面是配置步骤:

一、在SSH Client生成ssh key pair

root@ceph01:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
1e:f1:c6:c5:c4:8e:e0:b3:ed:9f:2c:::ce:8a:0d root@ceph01
The key's randomart image is:
+--[ RSA ]----+
| .. |
| . o. |
| ... oo |
| . ++... |
| o oS++ |
| E o.ooo |
| + . .o . |
| . o o. . |
| o+ |
+-----------------+

二、复制id_rsa.pub内容到 SSH Server 用户的.ssh/authorized_keys 中

root@ceph01:~# ssh-copy-id ceph02
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@ceph02's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'ceph02'"
and check to make sure that only the key(s) you wanted were added.

查看SSH Server 用户的.ssh/authorized_keys文件内容

root@ceph02:~/.ssh# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1hXDFOCI0hdsZlvuP9FGLnCd6k6yR51T6WN4+Wr/shJlY6ymcxde2hwBhiGowvKNbhpVA3EHUxtV0W9YH742ymTmUCVBCuGd2zUwB36AR9aiQGFwSd8vulqaybirpsic9iZ4d83cGjdJwSQg5mGhxZpzi4qD8yygdEDkTcczIFj+9zh5BCIlsZXFHU8044wIKBAbp2YvrsCW0L81XvVJZo3OJxggbUYlMhXcws99U7q2JcBUKv9IQYjar9GyYh4DNlllDs56sfR6SDtuT1O6NOtKSCc6jxCpf7EmxgBXIeYQiSUKnwDo3CE4FmvFsmTlkFUkOluJIRGUTbkokw5tJ root@ceph01

三、在SSH Server上修改sshd_config配置文件

Port
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol
# HostKeys for protocol version
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes # Lifetime and size of ephemeral version server key
KeyRegenerationInterval
ServerKeyBits # Logging
SyslogFacility AUTH
LogLevel INFO # Authentication:
LoginGraceTime
PermitRootLogin yes
StrictModes yes RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys # Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version
HostbasedAuthentication no
.
.
.

四、验证

root@ceph01:~# ssh root@ceph02
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.--generic x86_64) * Documentation: https://help.ubuntu.com/ System information as of Wed Jan :: CST System load: 0.0 Processes:
Usage of /: 3.7% of .95GB Users logged in:
Memory usage: % IP address for eth0: 192.168.20.178
Swap usage: % Graph this data and manage this system at:
https://landscape.canonical.com/ packages can be updated.
updates are security updates. New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it. Last login: Wed Jan :: from 192.168.20.116
root@ceph02:~#

ubuntu ssh免密码登录的更多相关文章

  1. ubuntu ssh 免密码登录

    1 ssh 是什么? ssh 是一种 加密协议,ssh 是两个加密的密码,一个是公钥一个是私钥,公钥加密的信息只有是要才能解密.ssh协议可用于服务之间的通信.例如:登录验证,git的授权等等 2 s ...

  2. Mac下到Linux主机ssh免密码登录

    最近忙得忘乎所以,写篇博客放松放松,RT,直接上命令好了 # Local ssh-keygen -t rsa scp ~/.ssh/id_rsa.pub username@server:~/.ssh/ ...

  3. 如何配置ssh免密码登录

    [TOC] 如果你在管理一堆unix机器,每次登录都要输入密码是挺烦的事情,一方面为了安全我们一般不会将所有机器的密码都设置成一样,另一方面就算一样每次都输入一遍也很麻烦. 这种情况下我们一般是用ss ...

  4. Linux 配置ssh 免密码登录

    在平常应用中,我们经常会登录到其他主机,比如说服务器,每次都需要用户名和密码. 我们可以通过ssh免密码登录服务器而不需要输入密码. 现在有一台ubuntu的阿里云服务器,称之为 server.  公 ...

  5. CentOS 6.5配置SSH免密码登录

    centos 系统对权限的设置非常微妙,如果权限设置大了则ssh 拒绝,如果权限小了,则ssh 更是被拒绝(我曾经配置好久没有打通,就是因为权限过大的原因) 参考链接:http://www.linux ...

  6. 安装Hadoop系列 — 安装SSH免密码登录

    配置ssh免密码登录   1) 验证是否安装ssh:ssh -version显示如下的话则成功安装了OpenSSH_6.2p2 Ubuntu-6ubuntu0.1, OpenSSL 1.0.1e 11 ...

  7. ssh免密码登录机器(使用公钥和秘钥进行加密来实现)

    ssh 无密码登录要使用公钥与私钥.linux下可以用用ssh-keygen生成公钥/私钥对,下面我以CentOS为例. 登录的原理: 有机器A(192.168.1.155),B(192.168.1. ...

  8. linux 配置ssh免密码登录

    1.确保主机名唯一 主机名修改方法: a.修改/etc/sysconfig/network,HOSTNAME=想要设置的主机名称 b.修改/etc/hosts,127.0.0.1   localhos ...

  9. centos ssh 免密码登录

    最近在学习的过程中遇到这个问题: A主机和B主机: A 免密码登录B: 首先在A的 ~/.ssh 目录中 执行 ssh-keygen -t rsa 一路回车 最后生成连个文件: 将id_rsa.pub ...

随机推荐

  1. mysql UNION all 实现不对称数据统计

    当统计多条的三个参数在不同时间段的数据的sum,又只能写在同一个sql上时,可以考虑union all三次查询, select * from ( select kk.a_time as dates,k ...

  2. Linux下用户管理、目录结构

    linux的文件系统是采用层级式的树状目录结构,在此结构中的最上层是根目录“/”,然后在此目录下再创建其他的目录. 目录介绍: / root,存放root用户的相关文件 home,存放普通用户的相关文 ...

  3. APP https抓包

    一.软件准备 charles 安卓模拟器(windows系统用逍遥模拟器,mac os 用夜神安卓模拟器) Xposed的apk安装包(安装到模拟器上),地址:http://repo.xposed.i ...

  4. 第二十二篇:C++中的多态机制

    前言 封装性,继承性,多态性是面向对象语言的三大特性.其中封装,继承好理解,而多态的概念让许多初学者感到困惑.本文将讲述C++中多态的概念以及多态的实现机制. 什么是多态? 多态就是多种形态,就是许多 ...

  5. 47、ListView setSelection() 和 setSelectionFromTop()

    http://blog.csdn.net/manoel/article/details/39183025 http://blog.csdn.net/a859522265/article/details ...

  6. 【BZOJ2730】[HNOI2012]矿场搭建 Tarjan

    [BZOJ2730][HNOI2012]矿场搭建 Description 煤矿工地可以看成是由隧道连接挖煤点组成的无向图.为安全起见,希望在工地发生事故时所有挖煤点的工人都能有一条出路逃到救援出口处. ...

  7. 获取html元素所在页面的坐标

    function findPosition(oElement) { var x2 = 0; var y2 = 0; var width = oElement.offsetWidth; var heig ...

  8. python系列十:python3函数

    #!/usr/bin/python #-*-coding:gbk-*- '''函数的简单规则:    函数代码块以 def 关键词开头,后接函数标识符名称和圆括号 ().    任何传入参数和自变量必 ...

  9. iOS 横竖屏适配

    关于横竖屏适配 也没做过,今天读别人的源码,遇到了.为了了解清楚,就系统的学习一下. 一 横竖屏方向枚举 关于横竖屏一共有三种枚举 UIInterfaceOrientation UIInterface ...

  10. Delphi运算符及优先级

    单目运算符 (最高优先级) @ 取变量或函数的地址(返回一个指针) not 逻辑取反或按位取反 乘除及按位运算符 * 相乘或集合交集 / 浮点相除 div 整数相除 mod 取模 (整数相除的余数) ...