ssh免口令密码登录及兼容性处理

  1. client ---> server

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

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

    注意:
    公钥加密私钥解;私钥加密公钥解。
    可以发布公钥,但私钥是不能出本机的。
    把公钥给谁就授信谁,信任谁的身份。

$ ssh-keygen -t rsa
不需要给passphrase,同时初次会在用户家目录下生成.ssh/,且生成id_rsa和id_rsa.pub两个文件。
也可以使用如下命令
$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
  1. 将客户端的公钥复制到服务器端
$ scp .ssh/id_rsa.pub [email protected]:~/.ssh/
这里192.168.0.11是服务器,user是服务器上的用户。
  1. 服务器上的操作
$ cat id_rsa.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
.ssh/需要700权限

上述3和4步可以合成如下一步完成:
$ ssh-copy-id 192.168.0.11
或者
$ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

最后服务器上配置 /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 [email protected]

或者修改配置文件 ~/.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 [email protected]

或者修改配置文件 ~/.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 [email protected]
  • ssh登陆兼容性问题处理实例
$ ssh [email protected]
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 [email protected]
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
[email protected]
aes128-ctr
aes192-ctr
aes256-ctr
[email protected]
[email protected]om
[email protected]

$ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -c aes128-cbc [email protected]

debug:
$ ssh -vvvv -oKexAlgorithms=+diffie-hellman-group1-sha1 -c 3des-cbc [email protected]

配置文件 ~/.ssh/config

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

原文地址:https://www.cnblogs.com/cerana/p/11179649.html

时间: 2024-08-29 22:44:13

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

centos7 ssh免口令认证登录

摘要:centos7, xshell, 公钥,  ssh ssh登录方式有口令认证登录和密钥认证登录 接下来本次介绍是ssh密钥登录方式 (1)产生公钥 (2)将公钥放置到centos7的(/root/./ssh)目录中 (3)然后添加ssh用户 因为我下载的xshell以中文,产生公钥的过程如图: 首先选择xshell里面的工具 选择新建用户密钥生成向导(数字签名RSA和DSA 默认RSA) 密钥长度2048 点击下一步 点击下一步 可以更改你密钥名称及其密钥加密密码 然后继续下一步 将其导出

使用openssh实现免密码登录,免用户名+密码登录

有时候经常登录某台主机,会懒得输入密码,输入个用户名登录,像我这种更懒的,密码也懒得输入: 创建虚拟机:centos7 HuaiqingdeMBP:~ huaiqingcheng$ vagrant box add centos7 /Users/huaiqingcheng/Downloads/centos-7.0-x86_64.box ==> box: Box file was not detected as metadata. Adding it directly... ==> box: Ad

ssh免秘钥登录

SSH免秘钥登录 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责 [[email protected] ~]# ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):    直接回车Enter passphrase (empty for no passphrase):  直接回车Enter

多节点ssh免密匙登录

1,在所有节点上,使用yourname用户名执行: ssh-keygen -t dsa -P '' -f /home/yourname/.ssh/id_dsa 2,在node1的/home/yourname/.ssh目录下,执行 : cat id_dsa.pub > authorized_keys 3,将node1上的authorized_keys拷贝到node2的相同目录下,执行: scp /home/yourname/.ssh/authorized_keys [email protected

zabbix3.0 监控mysql服务免用户名密码登录的问题故障处理详细过程

1,My.cnf中用户名密码无效 在azure云上面,使用Zabbix监控mysql中,发现在/usr/local/mysql/my.cnf里面设置的默认用户名密码无效,出不来数据,而且在zabbix服务器上,使用zabbix_get也报错failed,如下 [[email protected]_serv_121_12 ~]#/usr/local/zabbix/bin/zabbix_get -s 192.168.13.13 -p10050 -kmysql.status[Uptime] /usr/

ssh免密远程登录(一)

--------------------------------------------------超级用户下,ssh免密登录------------------------------------ 环境介绍: 主机1:ip 192.168.200.142 主机2:ip 192.168.200.158 用户要求:主机一 对 主机二 进行免密登录. 命        令:ssh scp ,     需要安装包:openssh-clients 免密过程: 1, ssh-keygen -t rsa (

谷歌云ssh开启root密码登录

修改配置 1.先选择从浏览器打开ssh连接服务器 连接登录成功后,输入以下命令 sudo -i #切换到root passwd #修改密码 然后会要求输入新密码,然后再重复一次密码,输入密码的时候不会显示出来,所以直接输入密码,然后回车,再然后重复输入密码回车. 修改root密码完成 2.接着修改SSH配置文件/etc/ssh/sshd_config vi /etc/ssh/sshd_config #编辑文件 找到以下内容并修改 PermitRootLogin yes //默认为no,需要开启r

Linux下配置ssh免密远程登录

步骤 使用ssh-keygen生成密钥对 提示要求输入保存的位置,密码等信息.全部使用默认信息即可 使用ssh-copy-id [email protected]将公钥拷贝到需要免密登录的服务器的账户中. 例如,需要免密登录192.168.199.124的pi用户,则需要ssh-copy-id [email protected],输入pi用户的密码. 以后即可免密登录到该账户. 原文地址:https://www.cnblogs.com/zhuxiaoxi/p/8430740.html

linux系统下ssh免秘钥登录

我有两台linux主机: 主机名分别是: lsx01.com lsx02.com 希望在lsx01.com这台主机上无秘钥登录lsx02.com. 一.修改hosts文件 在两台机器上都添加主机ip信息 例如在lsx01.com上: vi /etc/hosts 配置如下: 二.生成rsa秘钥文件,统一拷贝至一个authorized_keys中 1.在所有主机上,例如lsx01.com主机上生成rsa秘钥文件 cd /root/.ssh ssh-keygen -t rsa 三下回车 生成了两个文件