ssh - ansible - "sudo: a password is required\r\n" -


quick question

i have setup ubuntu server user named test. copy authorized_keys it, can ssh no problem. if $ ansible -m ping ubu1, no problem response

    <i><p>ubu1 | success => {         <br>"changed": false,          <br>"ping": "pong"     <br>}</i> 

what dont this, if do

$ ansible-playbook -vvvv playbooks/htopinstall.yml

fatal: [ubu1]: failed! => {"changed": false, "failed": true, "invocation": {"module_name": "setup"}, "module_stderr": "openssh_7.2p2 ubuntu-4ubuntu2.1, openssl 1.0.2g-fips  1 mar 2016\r\ndebug1: reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: applying options *\r\ndebug1: auto-mux: trying existing master\r\ndebug2: fd 3 setting o_nonblock\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 6109\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: broken pipe\r\ndebug2: received exit status master 1\r\nshared connection 192.168.1.112 closed.\r\n", "module_stdout": "sudo: password required\r\n", "msg": "module failure", "parsed": false} 

if $ ansible-playbook --ask-sudo-pass playbooks/htopinstall.yml, ask user password , play success.

if rename authorized_keys tells me "failed connect host via ssh." ok. dont understand why asking sudo password. definetly missed along way.

my ansible.cfg file looks this

[defaults] nocows = 1 inventory = ./playbooks/hosts remote_user = test private_key_file = /home/test/.ssh/id_ubu host_key_checking = false 

my hosts file looks this

[servers] ubu1 ansible_ssh_host=192.168.1.112 ansible_ssh_user=test 

what dont understand why asking sudo password.

we can't without seeing playbook, it's because a) playbook asks ansible run particular command sudo (via sudo or become directives) , b) test user not have password-less sudo enabled.

it sounds aware of (a) confused (b); specifically, i'm picking don't understand difference between ssh authentication , sudo authentication. again, without more information can't confirm if case, i'll take stab @ explaining in case guessed correctly.

when connect machine via ssh, there 2 primary ways in sshd authenticates , allows log in particular user. first ask account's password, hands off system, , allows login if correct. second through public-key cryptography, in prove have access private key corresponds public key fingerprint in ~/.ssh/authorized_keys. passing sshd's authentication checks gives shell on machine.

when invoke command sudo, you're asking sudo elevate privileges beyond account gets. entirely different system, rules defined in /etc/sudoers (which should edit using sudo visudo) control users allowed use sudo, commands should able run, whether need re-enter password or not when using command, , variety of other configuration options.

when run playbook normally, ansible presented sudo prompt , doesn't know how continue - doesn't know account password. that's why --ask-sudo-pass exists: you're giving password ansible can pass on sudo when prompted. if don't want have type every time , you've decided it's within security parameters allow logged in test user perform action root, can consult man sudoers on how set passwordless sudo account.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -