1). client ---> server

客户端发起对服务器的连接,登录服务器。

2). 须在客户端生成密钥对

注意:

公钥加密私钥解;私钥加密公钥解。

可以发布公钥,但私钥是不能出本机的。

把公钥给谁就授信谁,信任谁的身份。

$ ssh-keygen -t rsa
不需要给passphrase,同时初次会在用户家目录下生成.ssh/,且生成id_rsa和id_rsa.pub两个文件。
也可以使用如下命令
$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

3). 将客户端的公钥复制到服务器端

$ scp .ssh/id_rsa.pub user@192.168.0.11:~/.ssh/
这里192.168.0.11是服务器,user是服务器上的用户。

4). 服务器上的操作

$ cat id_rsa.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
.ssh/需要700权限 注意,文件.ssh/authorized_keys的格式如下:
-------------------------------------------------------------------------
ssh-rsa AAAAB3NzaC1...... user1@node01
ssh-rsa AAAAB3PzcIIE1...... user2@node02
ssh-rsa AAAAB3NzaC1...... user3@node03
-------------------------------------------------------------------------
一行一个公钥密钥串(UNIX回车换行,可以用vim的o指令添加)。
每行以ssh-rsa开头,最后为描述信息,形如:user1@node01。描述信息是可选的。 上述3和4步可以合成如下一步完成:
$ ssh-copy-id 192.168.0.11
或者
$ ssh-copy-id -i ~/.ssh/id_rsa.pub bee@192.168.1.1 最后服务器上配置 /etc/ssh/sshd_config 并重启服务:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

关于兼容性:

  • 对于错误

Unable to negotiate with legacyhost: no matching key exchange method found.

Their offer: diffie-hellman-group1-sha1

使用如下命令设置

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@legacyhost

或者修改配置文件 ~/.ssh/config
Host somehost.example.org (域名或IP)
KexAlgorithms +diffie-hellman-group1-sha1
  • 对于错误

Unable to negotiate with legacyhost: no matching host key type found. Their offer: ssh-dss

使用如下命令设置

ssh -oHostKeyAlgorithms=+ssh-dss user@legacyhost

或者修改配置文件 ~/.ssh/config
Host somehost.example.org (域名或IP)
HostKeyAlgorithms +ssh-dss
  • 查询ssh支持的算法
ssh -Q cipher       # List supported ciphers
ssh -Q mac # List supported MACs
ssh -Q key # List supported public key types
ssh -Q kex # List supported key exchange algorithms
  • 查询连接特定主机时所使用的配置
ssh -G user@somehost.example.com
  • ssh登陆兼容性问题处理实例
$ ssh user@192.168.1.10
Unable to negotiate with 192.168.1.10 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 $ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@192.168.1.10
Unable to negotiate with 192.168.1.10 port 22: no matching cipher found. Their offer: aes256-cbc,aes128-cbc,3des-cbc,des-cbc $ ssh -Q cipher
3des-cbc
aes128-cbc
aes192-cbc
aes256-cbc
rijndael-cbc@lysator.liu.se
aes128-ctr
aes192-ctr
aes256-ctr
aes128-gcm@openssh.com
aes256-gcm@openssh.com
chacha20-poly1305@openssh.com $ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -c aes128-cbc user@192.168.1.10 debug:
$ ssh -vvvv -oKexAlgorithms=+diffie-hellman-group1-sha1 -c 3des-cbc user@192.168.1.10

配置文件 ~/.ssh/config

Host 192.168.1.10 example.org
user someone
KexAlgorithms diffie-hellman-group1-sha1
Cipher 3des-cbc

ssh免口令密码登录及兼容性处理的更多相关文章

  1. centos7 ssh免口令认证登录

    摘要:centos7, xshell, 公钥,  ssh ssh登录方式有口令认证登录和密钥认证登录 接下来本次介绍是ssh密钥登录方式 (1)产生公钥 (2)将公钥放置到centos7的(/root ...

  2. 利用系统自带工具快速实现SSH免密远程登录

    一.软件环境 操作系统:CentOS Linux release 7.4.1708 (Core) SSH版本 [root@Geeklp201 ~]# ssh -V OpenSSH_7.4p1, Ope ...

  3. Linux SSH 免秘钥登录

    SSH 免秘钥登录 ssh:是一种安全加密协议 ssh  username@hostname     ssh gongziyuan.com:以当前用户登录该机器(如果不是当前用户,需要这么干:ssh ...

  4. linux下ssh免秘钥登录

    1.检查防火墙是否关闭 (1)切换到root用户 (2)查看防火墙状态 service iptables status 这是没有关闭 (3)设置关闭 service iptables stop 2.检 ...

  5. 多节点ssh免密匙登录

    1,在所有节点上,使用yourname用户名执行: ssh-keygen -t dsa -P '' -f /home/yourname/.ssh/id_dsa 2,在node1的/home/yourn ...

  6. ssh 免密root登录

    安装SSH SERVER 在所有的节点上都安装SSH server服务. # apt-get install openssh-server1 因为我们搭建的Ceph直接使用root用户,所以需要修改s ...

  7. L07-Linux配置ssh免密远程登录

    本文配置可实现:集群服务器之间相互可以ssh免密登录.若只想从单一机器(如master)ssh免密登录其他机器(slave1.slave2),则只跟着操作到第二步即可. 建议先花两三分钟把全文看完再跟 ...

  8. 谷歌云ssh开启root密码登录

    修改配置 1.先选择从浏览器打开ssh连接服务器 连接登录成功后,输入以下命令 sudo -i #切换到root passwd #修改密码 然后会要求输入新密码,然后再重复一次密码,输入密码的时候不会 ...

  9. ssh免秘钥登录

    简介 SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group)所制定:SSH 为建立在应用层基础上的安全协议.SSH 是目前较可靠,专为远程 ...

随机推荐

  1. 使用visual studio配置和运行《opengl圣经》的第一个案例

    对vc++新手来说,想把opengl圣经里的教学案例运行起来还真不是一件容易的事情,而且并没有完整的操作流程教学,这里就总结一下吧: 先安装cmake,用于生成vs的工程文件,安装过程中选中“将目录添 ...

  2. es的调优

    3.1.分片查询方式 当前的图片中有5个主分片,5个副本:这对于es的集群来说,这种配置是非常常见的: 但是问题来了,当我们的客户端做查询的时候,程序会向主分片发送请求还是副本发送请求? 还是说直接去 ...

  3. 《Vue前端开发手册》

    序言 为了统一前端的技术栈问题,技术开发二部规定开发技术必须以Vue为主. 为了更好的规范公司的前端框架,现以我前端架构师为主,编写以下开发规范,如有不当的地方,欢迎批评教育并慢慢改善该开发文档,谢谢 ...

  4. 麦子lavarel---10、一些第三方应用注意

    麦子lavarel---10.一些第三方应用注意 一.总结 一句话总结: 其实把重要的几个功能弄一个就好了,邮箱验证,手机号验证,支付验证,都是调用第三方接口,也很简单 1.关于页面和服务端校验的看法 ...

  5. PHP必备函数详解

    PHP必备函数详解

  6. Linux内核调试方法总结之bugreport

    bugreport [用途]Android性能分析工具,bugreport记录了Android启动过程日志,启动后的系统状态,包括进程列表.内存信息.VM信息等 [使用方法] Adb bugrepor ...

  7. fedora禁用(开机启动)服务和进程管理

    首先要查看有哪些(开机启动)服务 chkconfig --list 或者: systemctl list-units 然后, 根据需要进行禁用服务的开机启动: chkconfig service_na ...

  8. ArrayBlockingQueue 源码分析

    ArrayBlockingQueue ArrayBlockingQueue 能解决什么问题?什么时候使用 ArrayBlockingQueue? 1)ArrayBlockingQueue 是底层由数组 ...

  9. unittest框架扩展(基于代码驱动)自动化-下

    一.数据驱动/代码驱动优缺点: 使用数据驱动的好处:- 代码复用率高.同一测试逻辑编写一次,可以被多条测试数据复用,提高了测试代码的复用率,同时可以提高测试脚本的编写效率.- 异常排查效率高.测试框架 ...

  10. 使用MarkDown的编辑器

    今天找到了一个比较全的markdown格式说明http://www.appinn.com/markdown/#precode,特别是代码标注的时候 多行的时候 使用 ... ... .. .. 可以把 ...