Cannot setup ssh public key
Hey,
I'm trying to install a ssh public key on a ubuntu 12.04 machine for a user unison. The keys are generated with PuTtyGen on a windows machine. The home directory of user unison has a .ssh-dir with nothing inside. When I run bighstate by
salt-call --local state.highstate -l debug
with the following state:
ssh-key-unison:
ssh_auth:
- present
- user: unison
- source: salt://unison/public_key_unison.id_rsa.pub
- enc: ssh-rsa
ant this contents of public_key_unison.id_rsa.pub:
---- BEGIN SSH2 PUBLIC KEY ---- Comment: "rsa-key-20130723" AAAAB3NzaC1yc2EAAAABJQAAAIB+QjbJjsAWPcGqPNfj5ZVt8BKwaSI+BsFxKwo+ 9dVMmKNJir4vF6ETqM6PFvQcw5eMj8lbbjzMOhvFkzTr0NEGWcboozMEs+k64vwt 7XqHDzRU02vKgrpa8XtEnXhVDOgd/2taKH4gm0QHkYy+/ImExJ1329bN+lUMwmR8 z7++5w== ---- END SSH2 PUBLIC KEY ----
the output of salt is:
State: - ssh_auth
Name: ssh-key-unison
Function: present
Result: True
Comment: The authorized host key ssh-key-unison is already present for user unison
Changes:
That is not true. The ~/.ssh of user unison is empty!
Best regards, majo83
I think there is an issue with the format of the public key. When I do run a ssh-keygen, I get a format for the public key like this:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBqQ+CsIUUaSo7FlyJLKc61WcGiNuaYIAEDugYQyU9lF0goBDigM8U+V8dtRW1bwJLYanWOZYDFtmtrljC7LkZV9iIXAtOsPiuSUCQ/p14/i+2jam0ap1/2rBfBp//DNocEVtu0cmwo40T6xmhxWF0vdEyyLU3Ubr8kdr+szwHujf/kmGnIZ6T8Yn2XwGfDADgOV/KosMYttJyvymg3luLqQke+eNgmI2uxHS/FCH7PX7CBFS/a4pFYQHrVcFadxlzL2RPqS0fMlwN16W0BPQkomVayS2heqDjyBCwuHhm5Bo/HLcN3Cw3Ss4a6qNvGHIY/72yGujGuWEsrT+/er7p unison@linux-buildserver
In this case however, salt should complain about the erranious format and not pretend the file is installed correclty.
Yes, the format is almost certainly the issue. It is odd that it says the key is present but doesn't even create the file, however.
We'll look into it. thanks for the report.
@majo83 This is fixed in #6290. I also added some instructions in that commit that show how to take the keypair that you generated with PuTTYgen and generate an OpenSSH-compatible public key, so you might want to take a look at the details for the pull request if you're not already aware of how to do so.
Thanks very much for the report, people like you help us make Salt even more awesome!