2
respostas

172.17.177.40 | UNREACHABLE!

Olá. Estou a mensagem acima. Vou anexar os códigos. Sendo que estou usando Windows. mas instalado o bash Ubunto e montei a maquina wordpress no virtual box. Ou seja. Meu ansible esta na maquina Ubunto fora do virtual Box e a maquina wordpress no virtual.

vagrantfile

Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/trusty64"

  config.vm.provider "virtualbox" do |v|
    v.memory = 1024
  end

  config.vm.define "wordpress" do |m|
    m.vm.network "private_network", ip: "172.17.177.40"
  end

end

Hosts

[wordpress]
172.17.177.40

Chave Criada no servidor Wordpress (Virtual Box)

vagrant@vagrant-ubuntu-trusty-64:~$ cd .ssh/
vagrant@vagrant-ubuntu-trusty-64:~/.ssh$ ls -l
total 4
-rw------- 1 vagrant vagrant 868 May  7 23:12 authorized_keys
vagrant@vagrant-ubuntu-trusty-64:~/.ssh$ cat authorized_keys
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1kDkp4NQHgoD++r4lZWR2SKl3QUttEINced0cIE5amRRHhGGQNZnXMkPe0JV1f35mWx33qyfzPybF1zHuDsfyF5bRwiZih3pGDm6oQ++lZBnZpHKKauHNII+xaprLHnosZLThLeA71dciasOFPnHzbW5TERQiTu9HeCQ90pL9kmGGP/0lWkbir1iPhpeq/DiWOj/oo4dGSx3vvrcXV6MZXCka2/ayrfgs+cVVdjiV+md7M2ubqhnsNMkt/1rSdlnzgvxUUV9yVMij02FG1m2Pe0O4eyZVVUfJTj6v9Ag3o+HJa4HASxGashrb50o2uTYSaGEa281toSaNzANUdwgP vagrant
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtz496qrshQ2Vr8zKqRilcOxAcFPWTiS3miKnC5EMqDzSdoZ/xPnlTSNDPUD9ZWCzx07I9iqpV+rJL6jIGa5xuFaWfOBIqyg70C0Vpfh8HxUCuAoz/IxeVcvJw/6YwhyDrMc+tyAMdceBI6Tza0a3CLFrI5ph89saPQnJr1wJmbv6/TCiyWilXuEA5RIBN5FKTsRKXil6pS1koRBYOJ0TtDqzdm5XAT56STnol4bmDGkxOtNpxwjFKh1g8xTH76N4jD3tdCDFa5VNVxc4YLb8HT9FaFPY9warNBXRkEfk9c/dyQ1Q3DBQ3xocGg0FaUGTkvPa3C9B6/3MOBO5COxFZ root@LAPTOP-L2H365L7
vagrant@vagrant-ubuntu-trusty-64:~/.ssh$
2 respostas

mas mesmo apos a copia da chave. ainda estou recebendo o erro.

root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys# ssh-copy-id -i vagrant_id_rsa.pub vagrant@172.17.177.40
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "vagrant_id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(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 new keys
vagrant@172.17.177.40's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'vagrant@172.17.177.40'"
and check to make sure that only the key(s) you wanted were added.

root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys#
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys#
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys#
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys# cd ..
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible#
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible#
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible#
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible# ansible wordpress -i hosts -u vagrant --private-key ssh-keys/vagrant_id_rsa -m ping -m shell -a 'echo Hello, World'
 [WARNING] Ansible is in a world writable directory (/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible), ignoring it as an ansible.cfg source.
172.17.177.40 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nPermissions 0777 for '/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys/vagrant_id_rsa' are too open.\r\nIt is required that your private key files are NOT accessible by others.\r\nThis private key will be ignored.\r\nLoad key \"/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys/vagrant_id_rsa\": bad permissions\r\nvagrant@172.17.177.40: Permission denied (publickey,password).\r\n",
    "unreachable": true
}
root@LAPTOP-L2H365L7:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible# cd ..

Olá José Roberto.

Provavelmente você já conseguiu resolver o problema. Mas caso alguém venha parar aqui com a mesma dúvida, creio que o erro seja por conta das permissões da chave privada. Pelo que diz a mensagem ela está com 0777. Tente configurar com 0400

chmod 0400 CAMINHO_PARA_A_CHAVE_PRIVADA

OBS: você não consegue alterar as permissões se a chave estiver na partição Windows (ex. /mnt/c). Copie ela para seu ambiente Linux (WSL), por exemplo: "/home/usuario/private_key" e indique ela no seu comando do Ansible.