Is there a single line command to tell SSH to add a provided public key to the local machine's
authorized_keys file? A local version of
I am writing a chef recipe and want to ensure a specific ssh public key is set for a certain user. I could overwrite the
~/.ssh/authorized_keys file each time, or attempt to some hacky way to add the line, but if there's an official command, it'll be more robust and prevent duplication.
ssh-add-local-key "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDeblahdeblah user@somwhere"
For apt systems like Ubuntu or Debian there is an
apt-add-repository command, so I wonder if there's a SSH equivalent.
Update: I know I could use "echo blah >> authorized_keys", but I want something idempotent, which I can run regularly. With
>> the file will grow in size every time.