ubantu离线安装ansible_ubuntu上安装ansible

本文介绍了如何在最新版Ubuntu上离线安装Ansible,并详细阐述了生成SSH密钥对以及设置SSH免密登录到目标节点的步骤。包括ssh-keygen命令创建密钥对,ssh-copy-id用于复制公钥到远程节点,以及解决SSH登录问题的配置方法。
摘要由CSDN通过智能技术生成

1 在最新的ubuntu系统上安装ansible : sudo ape-get install ansible

2 切换到root用户 生成ssh免密登陆

ssh-keygen -t rsa

ssh-copy-id -i /root/.ssh/id_rsa.pub root@ip(ip是被ansible管理的节点地址)

root@pxy-p:/etc/ansible# ssh-keygen -t rsa

Generatingpublic/privatersa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (emptyforno passphrase):

Enter same passphrase again:

Your identification has been saved in/root/.ssh/id_rsa.

Yourpublic key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:AsNJM46Bt5GCyQtaNXQOik+hKDAD9hRQZkIuMz3I/1g root@pxy-p

The key's randomart image is:

+---[RSA 2048]----+

|XB=XX . |

|%O@O O |

|%*B+* . |

|+*o. o |

| .. E. S |

| + . |

| . . |

| |

| |

+----[SHA256]-----+root@pxy-p:/etc/ansible# ssh-copy-id -i /root/.ssh/id_rsa.pub root@100.98.40.134

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the newkey(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the newkeys

root@100.98.40.134's password:

Number of key(s) added:1Nowtry logging into the machine, with: "ssh 'root@100.98.40.134'"and check to make sure that only the key(s) you wanted were added.

root@pxy-p:/etc/ansible# ssh 100.98.40.134Welcome to Ubuntu16.04.5 LTS (GNU/Linux 4.15.0-29-generic x86_64)* Documentation: https://help.ubuntu.com

* Management: https://landscape.canonical.com

* Support: https://ubuntu.com/advantage

6个可升级软件包。0个安全更新。

Last login: Tue Oct30 16:29:25 2018 from 100.98.40.167root@pxy-snow:~# exit

注销

Connection to100.98.40.134closed.

root@pxy-p:/etc/ansible#

如果ssh 免秘钥登陆节点失败:

解决方法:

1) 以root身份,chmod +w /etc/ssh/sshd_config

2) vi /etc/ssh/sshd_config

3) 将PermitRootLogin no改成PermitRootLogin yes

4) service sshd restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值