-2

I have set up some ansible roles to configure a php web server. I use vagrant to my working copy and it works perfectly. But when I want to connect to a remote server I get this error:

fatal: [xxxxxxx] => SSH Error: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
    while connecting to xxxxxxxxxx:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

I have the ssh key set on the server (Cent OS 7) so if I do:

ssh -l root XX.XX.XXX.XX 

I log in without problems.

Any idea why its failing to log in to the server? Thanks

closed as off-topic by Jakuje, mdpc, kasperd, Jim B, Jenny D Mar 18 '17 at 11:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

Depending on your needs (e.g. whether you will be using ansible to create an unprivileged user, and no longer use root for login), you can also just run your play with some command line options:

ansible-playbook -u root <... rest of command line ..>

@hvindin's suggestion is otherwise a good one if you plan to use the root account more permanently.

2

You really should post the -vvvv logs as well as your ansible configuration. But taking a bit of a stab in the dark here, have you set the SSH user?

I'd hope that you aren't logging into every box as root, in which case if you want to connect to the other server as root you should specify something like this in your hosts file:

[group]
hostname.com ansible_user=root

Not the answer you're looking for? Browse other questions tagged or ask your own question.