salt icon indicating copy to clipboard operation
salt copied to clipboard

quoted space in authorized_keys confuses ssh.py

Open Foxlik opened this issue 9 years ago • 2 comments

Description of Issue/Question

In some cases (e.g. Ubuntu cloud-init) authorized_keys may contain quoted spaces as part of options:

no-port-forwarding,no-agent-forwarding,no-X11-forwarding,com‌​mand="echo 'Please login as the user \"ubuntu\" rather than the user \"root\".';echo;sleep 10" ssh-rsa xyzxyz [email protected]

which confuses the split in _replace_auth_key() in modules/ssh.py.

Applying state like this one:

    users_ssh_auth_root_0:
        ----------
        __env__:
            base
        __sls__:
            users.init
        ssh_auth:
            |_
              ----------
              user:
                  root
            |_
              ----------
              name:
                  ssh-rsa xyzxyz [email protected]
            |_
              ----------
              require:
                  |_
                    ----------
                    file:
                        user_keydir_root
                  |_
                    ----------
                    user:
                        users_root_user
            - present
            |_
              ----------
              order:
                  10018

Results in state reporting:

----------
          ID: users_ssh_auth_root_0
    Function: ssh_auth.present
        Name: ssh-rsa xyzxyz [email protected]
      Result: True
     Comment: The authorized host key xyzxyz for user root was updated
     Started: 18:14:14.556283
    Duration: 3.583 ms
     Changes:
              ----------
              xyzxyz:
                  Updated

but actually changing nothing.

Setup

Please see above

Steps to Reproduce Issue

Please see above

Versions Report

Salt Version:
           Salt: 2016.11.3

Dependency Versions:
           cffi: Not Installed
       cherrypy: 3.5.0
       dateutil: 2.4.2
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: Ubuntu 16.04 xenial
        machine: x86_64
        release: 4.4.0-62-generic
         system: Linux
        version: Ubuntu 16.04 xenial

Foxlik avatar Mar 06 '17 17:03 Foxlik

@Foxlik thanks for the PR! once that pr has been reviewed and merged please feel free to close this issue or we can.

Ch3LL avatar Mar 06 '17 21:03 Ch3LL

Fix has been merged. Closing.

rallytime avatar Mar 27 '17 21:03 rallytime