ssh免口令密码登录及兼容性处理
2020-04-08 07:41
1451 查看
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
转载于:https://www.cnblogs.com/cerana/p/11179649.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- ssh 无密码登录(转载加上我发现个小问题处理)
- CentOs 下ssh免密码登录
- SSH远程管理(用户登录控制及密码验证)
- Linux/CentOS启动SSH远程登录无密码
- 解决SUSE Linux下SSH无法使用密码登录问题
- SSH 登录失败:Host key verification failed 的处理方法
- 路由器登录SSH 登录思科路由器RSA modulus too small处理
- 嵌入式 SSH无密码验证登录的实现
- sshpass 配置密码登录ssh
- ssh完全无密码登录
- hadoop环境集群搭建与ssh免密码登录
- 解决ssh配置无密码登录后 又出现输入密码的情况--hadoop集群配置
- CentOS下配置ssh免密码登录
- linux 配置ssh无密码登录不起作用的解决方案
- SSH Without a Password(SSH无密码登录)
- SSH免密码登录
- SSH无密码登录-多节点自动化部署SHELL篇
- ssh 免密码登录
- centos7.0配置ssh免密码登录
- ssh 登录免密码设置