当前位置: 首页 > news >正文

ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

【ansible 设置host为localhost,执行ping命令报错】
[eniq-s@localhost ansible]$ ansible all -m ping -i inventory 
localhost | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
    "unreachable": true
}

https://serverfault.com/questions/1085427/ansible-playbook-not-running-for-localhost-also-how-to-fix-this

【加 -k 交互式输入密码可以成功】
[eniq-s@localhost ansible]$ ansible all -k -m ping -i inventory 
SSH password: 
localhost | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}

https://wenku.baidu.com/view/4a4a69f64a649b6648d7c1c708a1284ac85005a7.html?_wkts_=1677651890658&bdQuery=authorized_keys%E6%96%87%E4%BB%B6%E5%9C%A8%E5%93%AA

【在local生成公钥,导入到server上的~/.ssh/authorized_keys, 之后问题解决】

[eniq-s@localhost ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/eniq-s/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/eniq-s/.ssh/id_rsa.
Your public key has been saved in /home/eniq-s/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:E3Hamok7mfc4bxwEdLSfCxqnmau9rMKqzUryhDyrMHM eniq-s@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|       .o.+      |
|        .* .     |
|        o.o      |
|       . =.. .   |
|      . S.o o    |
|..     + O.. .   |
|*+E.  = *. ..    |
|+Oo o  =.+o      |
|=+=. .oo*=o      |
+----[SHA256]-----+
[eniq-s@localhost ~]$ ls -alt .ssh/
total 12
drwx------.  2 eniq-s eniq-s   57 Feb 28 23:38 .
-rw-------.  1 eniq-s eniq-s 1679 Feb 28 23:38 id_rsa
-rw-r--r--.  1 eniq-s eniq-s  410 Feb 28 23:38 id_rsa.pub
drwx------. 10 eniq-s eniq-s  252 Feb 28 22:44 ..
-rw-r--r--.  1 eniq-s eniq-s  171 Feb 28 20:36 known_hosts
[eniq-s@localhost ~]$ 
[eniq-s@localhost ~]$ pwd
/home/eniq-s
[eniq-s@localhost ~]$ cat >> .ssh/authorized_keys  < .ssh/id_rsa.pub 

[eniq-s@localhost ~]$ ansible all  -m ping -i ./ansible/inventory   
localhost | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
 

http://www.lryc.cn/news/25436.html

相关文章:

  • 有限元中三角形的一些积分公式
  • 【docker-compose】安装mongodb
  • 【ClickHouse源码】物化视图的写入过程
  • .NET 使用NLog增强日志输出
  • 一道阿里类的初始化顺序笔试题
  • cuda找不到路径报错
  • Elasticsearch进阶之(核心概念、系统架构、路由计算、倒排索引、分词、Kibana)
  • Android包体积缩减
  • 【华为OD机试】 网上商城优惠活动(C++ Java Javascript Python)
  • GWT安装过程
  • 代码随想录算法训练营第一天| 704. 二分查找、27. 移除元素
  • office@word@ppt启用mathtype组件方法整理
  • 计算机大小端
  • Matplotlib绘图从零入门到实践(含各类用法详解)
  • C语言 入门教程||C语言 指针||C语言 字符串
  • Nacos2.x+Nginx集群配置
  • Android源码分析 - InputManagerService与触摸事件
  • python库--urllib
  • 美团前端二面常考react面试题及答案
  • 环境搭建04-Ubuntu16.04更改conda,pip的镜像源
  • 【C++进阶】四、STL---set和map的介绍和使用
  • JavaSE学习进阶 day1_01 static关键字和静态代码块的使用
  • 苹果笔可以不买原装吗?开学必备性价比电容笔
  • 数据库连接与properties文件
  • Linux上的校验和验证
  • 杂记——14.git在idea上的使用及其实际开发介绍
  • 记一次Nodejs减低npm版本的踩坑日记
  • 【iOS】—— 初识RAC响应式编程
  • Java——面向对象
  • 电影《毒舌律师》观后感