ssh分发秘钥时出现错误“Permission denied (publickey,gssapi-keyex,gssapi-with-mic)”
因为公司的服务器连接是通过xshell公钥和密码连接的,今天在ssh分发秘钥的时候出现了,下面的错误:
[root@iZ2ze97cumk8opqm28h8Z .ssh]# ssh-copy-id -i /root/.ssh/id_dsa.pub "root@123.56.82.168 -p 52808"
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
于是上网上搜索,网上其他人提供的解决方案为:
(1)创建用户: ansible
(2)修改sshd_config文件
# vi /etc/ssh/sshd_config //开启以下内容
HostKey /etc/ssh/ssh_host_rsa_key
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
# /etc/init.d/sshd restart
(3)权限设置
# mkdir /home/ansible/.ssh
# chown -R ansible:ansible /home/ansible
# chmod 700 /home/ansible
# chmod 700 /home/ansible/.ssh
# chmod 644 /home/ansible/.ssh/authorized_keys //公钥文件的所有权限
# chmod 600 /home/ansible/.ssh/id_rsa //私钥文件的所有权限
### 可以测试远程连接了……
但是经过的我的测试还是不行,于是经过一番排查,得出来结果
其中这两项PubkeyAuthentication yes 和PasswordAuthentication no的值都要为yes,即公钥认证和密码认证都要为yes,因为我连接的方式是通过这两种方式来连接的,
[root@iZ2ze97cgcumk8opq8h8Z .ssh]# egrep "PubkeyAuthentication" /etc/ssh/sshd_config
#PubkeyAuthentication yes
PubkeyAuthentication yes
[root@iZ2ze97cgcuopqm28h8Z .ssh]# egrep "PasswordAuthentication" /etc/ssh/sshd_config
PasswordAuthentication no
于是将PasswordAuthentication的no替换为yes,结果没有出现那个错误了。但是密码好像不对。额。
[root@iZ2ze97cgcumopqm28h8Z .ssh]# ssh-copy-id -i /root/.ssh/id_dsa.pub "root@123.56.82.168 -p 52808"
root@123.56.82.168's password:
Permission denied, please try again.
root@123.56.82.168's password:
Permission denied, please try again.
root@123.56.82.168's password:
结果:清空/root/.ssh/目录下的known_hosts下即可。
ssh分发秘钥时出现错误“Permission denied (publickey,gssapi-keyex,gssapi-with-mic)”的更多相关文章
- $ ssh -T -v git@github.com_在本地用ssh连接github出错_git@github.com: Permission denied (publickey).
$ ssh -T -v git@github.com报错: debug1: Authentications that can continue: publickey debug1: Next auth ...
- Permission denied (publickey),Gitlab & Github 多ssh key 冲突 导致的权限问题
Github 多ssh key导致的权限问题 :Permission denied (publickey) 公司用gitlib搭建了git服务器,自己已有github账号,用ssh-keygen分别生 ...
- [置顶] github 出现 Permission denied (publickey)的解决
今天写了一篇博客,想push到github上的时候出现了以下错误 Permission denied (publickey). fatal: The remote end hung up unexpe ...
- IDEA中使用git报错Permission denied (publickey)
最近在使用idea开发时,使用git拉取远程仓库的代码时,报错Permission denied (publickey),原因是因为ssh的密钥失效,必须得重新设置下ssh的密钥即可. 命令很简单,在 ...
- SSH登陆阿里云服务器出现Permission denied (publickey)错误解决方案
操作环境: 操作系统:Mac10.11.5 阿里云服务器:Ubuntu16.04 远程连接:SSH 注:首先我们已假设你已经自己生成了SSH秘钥,并已经配置到阿里云.绑定了自己的云服务器. 但是后来发 ...
- expect配合shell 实现自动分发秘钥文件
expect使用场景 有时候需要批量地执行一些操作,或者执行自动化的操作的时候,有些指令需要交互式地进行这就会有很多麻烦,linux下有一个程序交expect,它可以模拟键盘输入文本,省去人工干预交互 ...
- ansible-playbook 打通ssh无秘钥
建议参考: http://www.cnblogs.com/jackchen001/p/6514018.html 这个代码清晰,效果佳! 参考链接: http://www.cnblogs.com/cao ...
- ssh 多秘钥管理和坑
概述 很久之前就想研究一下 ssh 的多秘钥管理,今天正好有时间就研究了一下,挺简单的,记录下来,供以后开发时参考,相信对其他人也有用. 参考资料: Git - 生成 SSH公钥 , Linux 下多 ...
- Linux SSH 免秘钥登录
SSH 免秘钥登录 ssh:是一种安全加密协议 ssh username@hostname ssh gongziyuan.com:以当前用户登录该机器(如果不是当前用户,需要这么干:ssh ...
随机推荐
- windows 结束进程的详细过程
windows上如何结束进程的详细过程,下面附详细,图文说明 在cmd下,输入 netstat -ano|findstr 8080 //说明:查看占用8080端口的进程 在cmd下, ...
- 新版本mac 无法打开第三方应用
新版本mac 没有任何应用可以打开的这个选项 现在解决方法已经找到 特此标记一下 1打开终端 2 输入 sudo spctl --master-disable 3.打开系统设置的中的安全即可出现
- js中判断对象数据类型的方法
对js中不同数据的布尔值类型总结:false:空字符串:null:undefined:0:NaN.true:除了上面的false的情况其他都为true: 如下: var o = { 'name':'l ...
- 初始Socket编程(python)
通信双方要有一个服务端和一个客户端,所以要分开去写代码. 所以我创建了两个py程序,第一个是服务端:iServer.py 和客户端 iClient.py 服务端: #coding:utf-8from ...
- Java数据结构和算法总结-冒泡排序、选择排序、插入排序算法分析
前言:排序在算法中的地位自然不必多说,在许多工作中都用到了排序,就像学生成绩统计名次.商城商品销量排名.新闻的搜索热度排名等等.也正因为排序的应用范围如此之广,引起了许多人深入研究它的兴趣,直至今天, ...
- JavaWeb(一)Servlet中的request与response
一.HttpServletRequest概述 1.1.HttpServletRequest简介 HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP ...
- Reshape the Matrix
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...
- 自测-5 Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- JDFS:一款分布式文件管理系统,第五篇(整体架构描述)
一 前言 截止到目前为止,虽然并不完美,但是JDFS已经初步具备了完整的分布式文件管理功能了,包括:文件的冗余存储.文件元信息的查询.文件的下载.文件的删除等.本文将对JDFS做一个总体的介绍,主要是 ...
- hdu 5954 -- Do not pour out(积分+二分)
题目链接 Problem Description You have got a cylindrical cup. Its bottom diameter is 2 units and its heig ...