ubuntu ssh免密码登录
目前很多服务(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免密码登录的更多相关文章
- ubuntu ssh 免密码登录
1 ssh 是什么? ssh 是一种 加密协议,ssh 是两个加密的密码,一个是公钥一个是私钥,公钥加密的信息只有是要才能解密.ssh协议可用于服务之间的通信.例如:登录验证,git的授权等等 2 s ...
- Mac下到Linux主机ssh免密码登录
最近忙得忘乎所以,写篇博客放松放松,RT,直接上命令好了 # Local ssh-keygen -t rsa scp ~/.ssh/id_rsa.pub username@server:~/.ssh/ ...
- 如何配置ssh免密码登录
[TOC] 如果你在管理一堆unix机器,每次登录都要输入密码是挺烦的事情,一方面为了安全我们一般不会将所有机器的密码都设置成一样,另一方面就算一样每次都输入一遍也很麻烦. 这种情况下我们一般是用ss ...
- Linux 配置ssh 免密码登录
在平常应用中,我们经常会登录到其他主机,比如说服务器,每次都需要用户名和密码. 我们可以通过ssh免密码登录服务器而不需要输入密码. 现在有一台ubuntu的阿里云服务器,称之为 server. 公 ...
- CentOS 6.5配置SSH免密码登录
centos 系统对权限的设置非常微妙,如果权限设置大了则ssh 拒绝,如果权限小了,则ssh 更是被拒绝(我曾经配置好久没有打通,就是因为权限过大的原因) 参考链接:http://www.linux ...
- 安装Hadoop系列 — 安装SSH免密码登录
配置ssh免密码登录 1) 验证是否安装ssh:ssh -version显示如下的话则成功安装了OpenSSH_6.2p2 Ubuntu-6ubuntu0.1, OpenSSL 1.0.1e 11 ...
- ssh免密码登录机器(使用公钥和秘钥进行加密来实现)
ssh 无密码登录要使用公钥与私钥.linux下可以用用ssh-keygen生成公钥/私钥对,下面我以CentOS为例. 登录的原理: 有机器A(192.168.1.155),B(192.168.1. ...
- linux 配置ssh免密码登录
1.确保主机名唯一 主机名修改方法: a.修改/etc/sysconfig/network,HOSTNAME=想要设置的主机名称 b.修改/etc/hosts,127.0.0.1 localhos ...
- centos ssh 免密码登录
最近在学习的过程中遇到这个问题: A主机和B主机: A 免密码登录B: 首先在A的 ~/.ssh 目录中 执行 ssh-keygen -t rsa 一路回车 最后生成连个文件: 将id_rsa.pub ...
随机推荐
- asp.net C#实现下载文件的六种方法实例
protected void Button1_Click(object sender, EventArgs e) { /* 微软为Response对象提供了一个新的方法TransmitFile来 ...
- 用js判断页面是否加载完成
这可以通过用document.onreadystatechange的方法来监听状态改变, 然后用document.readyState == “complete”判断是否加载完成. 可以采用2个div ...
- 关于java后台如何接收xml格式的数据
业务场景:用户发送下单请求,格式为xml格式,服务器接收数据完成下单,并返回结果给客户. 请求格式: <request> <head> <sign></sig ...
- Codeforces 678E Another Sith Tournament 状压DP
题意: 有\(n(n \leq 18)\)个人打擂台赛,编号从\(1\)到\(n\),主角是\(1\)号. 一开始主角先选一个擂主,和一个打擂的人. 两个人之中胜的人留下来当擂主等主角决定下一个人打擂 ...
- 关于微信小程序的开发步骤
~~~~包子最近在研究小程序 首先先讲一下小程序一些基本的步骤: 1.登录微信的公众平台,选择小程序,注册一个账号,期间有碰到什么交300块钱的就不要理他,因为我只是做demo,当然,准备上线的企业啥 ...
- rgba透明的兼容处理
background-color: rgba(0, 0, 0, .6);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr ...
- Windows下比较小巧的c/c++ ide
下载:codeblocks 只有几十兆. http://www.codeblocks.org/downloads/26#windows codeblocks-16.01mingw-nosetup.zi ...
- xx云网络实施方案案例
由于xx云在我公司进行试用,对接我方存储,于是乎就负责网络实施方案,下面是具体方案介绍 ip分配 具体网络拓扑如下: 下面是两台交换机配置 IPMI交换机配置如下: [Quidway]di cu !S ...
- corethink功能模块探索开发(三)让这个模块可见
感觉corethink把thinkphp的思想复用到淋漓尽致. 1.把opencmf.php文件配置好了后台该模块的菜单就能在安装后自动读取(分析好父子关系,否则页面死循环,apache资源占用率10 ...
- Linux:文件
Linux:文件 文件属性 用户分为三种:文件拥有者.群组以及其它人,对不同的用户有不同的文件权限. 使用 ls 查看一个文件时,会显示一个文件的信息,例如 drwxr-xr-x. 3 root ro ...