local ansible_ssh_port=22 ansible_ssh_host=localhost ansible_ssh_user=feng ansible_ssh_private_key_file=/Users/fengxuting/.ssh/id_rsa
---
- hosts: local
tasks:
# Sending an e-mail using 163 SMTP servers
- mail:
host: smtp.163.com
port: 25
username: fffy2366
password: xxx
from: fffy2366@163.com (fffy2366)
to: Frank feng <fengxuting@qq.com>
subject: Ansible-report
body: 'System {{ ansible_hostname }} has been successfully provisioned.'
delegate_to: localhost
ansible-playbook -i hosts mail.yml
ssh: connect to host localhost port 22: Connection refused
解决方法是选择系统偏好设置->选择共享->点击远程登录
然后再输入命令ssh localhost发现已经解决问题
加入公钥到~/.ssh/authorized_keys
ssh-copy-id feng@localhost
发表评论 登录: