无法将文件复制到远程主机

时间:2020-03-25 18:14:30

标签: ssh ansible

我确实创建了一个可在多个服务器上创建用户的ansible脚本,但我坚持将文件(id_rsa.pub)复制到远程服务器上并复制到该文件(authorized_keys)中,但根据文档的说明,一切正常过去,但现在该副本不再可用。

- name: Copy file with owner and permissions
  copy:
    src: /home/{{ user }}/.ssh/id_rsa.pub
    dest: /home/{{ user }}/.ssh/authorized_keys
    owner: "{{ user }}"
    group: "{{ user }}"
    mode: '0644'

来自远程计算机的日志结果(消息文件)如下。 用户确实成为sudo,连接正常。但到目前为止尚无法找到问题的可能原因。

Mar 25 14:11:51 localhost systemd: Started Session 13 of user klevin.
Mar 25 14:11:51 localhost systemd-logind: New session 13 of user klevin.
Mar 25 14:11:51 localhost ansible-setup: Invoked with filter=* gather_subset=['all'] fact_path=/etc/ansible/facts.d gather_timeout=10
Mar 25 14:11:52 localhost ansible-group: Invoked with state=present gid=None local=False name=rebel system=False
Mar 25 14:11:52 localhost ansible-lineinfile: Invoked with directory_mode=None force=None remote_src=None backrefs=False insertafter=None path=/etc/sudoers owner=None follow=False validate=/usr/sbin/visudo -cf %s group=None insertbefore=None unsafe_writes=None create=False state=present content=NOT_LOGGING_PARAMETER serole=None setype=None selevel=None regexp=^%rebel  ALL=\(ALL\) line=%rebel  ALL=(ALL)       ALL src=None seuser=None delimiter=None mode=None firstmatch=False attributes=None backup=False
Mar 25 14:11:53 localhost ansible-user: Invoked with comment=None ssh_key_bits=0 update_password=on_create non_unique=False force=False ssh_key_type=rsa create_home=True password_lock=None ssh_key_passphrase=NOT_LOGGING_PARAMETER uid=None home=None append=False skeleton=None ssh_key_comment=ansible-generated on localhost.localdomain group=None system=False state=present hidden=None local=None shell=/bin/bash expires=None ssh_key_file=None groups=['rebel'] move_home=False password=NOT_LOGGING_PARAMETER name=test seuser=None remove=False login_class=None generate_ssh_key=None
Mar 25 14:11:53 localhost ansible-file: Invoked with directory_mode=None force=False remote_src=None _original_basename=None path=/home/test/ owner=test follow=True group=test unsafe_writes=None state=directory content=NOT_LOGGING_PARAMETER serole=None selevel=None setype=None access_time=None access_time_format=%Y%m%d%H%M.%S modification_time=None regexp=None src=None seuser=None recurse=False _diff_peek=None delimiter=None mode=None modification_time_format=%Y%m%d%H%M.%S attributes=None backup=None
Mar 25 14:11:54 localhost ansible-file: Invoked with directory_mode=None force=False remote_src=None _original_basename=None path=/home/test/.ssh owner=test follow=True group=test unsafe_writes=None state=directory content=NOT_LOGGING_PARAMETER serole=None selevel=None setype=None access_time=None access_time_format=%Y%m%d%H%M.%S modification_time=None regexp=None src=None seuser=None recurse=False _diff_peek=None delimiter=None mode=None modification_time_format=%Y%m%d%H%M.%S attributes=None backup=None
Mar 25 14:11:54 localhost ansible-lineinfile: Invoked with directory_mode=None force=None remote_src=None backrefs=False owner=None path=/etc/ssh/sshd_config insertafter=AllowUsers*. follow=False validate=None group=None insertbefore=None unsafe_writes=None create=False setype=None content=NOT_LOGGING_PARAMETER serole=None state=present selevel=None regexp=None line=AllowUsers test src=None seuser=None delimiter=None mode=None firstmatch=False attributes=None backup=False
Mar 25 14:11:54 localhost ansible-stat: Invoked with checksum_algorithm=sha1 get_checksum=True follow=False checksum_algo=sha1 path=/home/test/.ssh/authorized_keys get_md5=None get_mime=True get_attributes=True

0 个答案:

没有答案
相关问题