ansible——ssh登录自定义端口,ansiblessh自定义


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

sshd_config
#Port 22
Port 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 root
192.168.3.102 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

相关内容

    暂无相关文章