ansible——ssh登录自定义端口

来源:互联网 发布:ubuntu卸载anaconda3 编辑:程序博客网 时间:2024/06/15 11:29

有些服务器会更改SSH端口,更改方法如下:

sshd_config#Port 22Port 65535

更改后使用新方式进行修改配置文件
ssh-copy-id “-p port user@host”

ssh-copy-id "-p 65535 user@192.168.3.102"

配置ansible的hosts配置文件
[port]
192.168.3.102
[port:vars]
ansible_ssh_user=”user”
ansible_ssh_port=65535

$ ansible port -m ping -u root192.168.3.102 | SUCCESS => {    "changed": false,     "ping": "pong"}
原创粉丝点击