wingrunr21/gitolite — Issue #10: Add ssh_key from string
Author: Nerian
Created: 2011-11-08 01:26:55+00:00
State: open

Hi Stafford,

Awesome Gem! Thanks for doing this.

I having some trouble adding a ssh key.

public_key

```bash
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4XIH/zioV68R2qJMrTmmnALWFsGzca/sJY8OuQCLeCZSKUtsrjfKAdL2UMxghSo6tiHYOoi7eai+EKpTwEow95tVpbRia8oeWOamzsLRP2ZhtQnuLIaknANBQl4ZszybQzLm6WV0/fsXaewPk5afSkSB5aZl8jpKQgDxILKc6sGLKjBNkOkr+iOC+sjoeDvWzTLZt6LOy1Sq4xO8qyDriqMD2GAhoGQl6kc0WtR7XfuifsWXB5iXOk+ZnTSSv9k7tEpXOf93tutv+9VNibItuNHVbprr5AWha58OcjF8r7baIT9NMXlnHHt6Pj+eRW2JGDX87pTvq3g0iCthe8U0R blabla
```

```ruby
admin_repo = Gitolite::GitoliteAdmin.new("gitolite-admin")

key = Gitolite::SSHKey.new("", public_key, "", "mike")
admin_repo.add_key(key)

admin_repo.save_and_apply
```

That end up actually adding this key:

```bash
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4XIH/zioV68R2qJMrTmmnALWFsGzca/sJY8OuQCLeCZSKUtsrjfKAdL2UMxghSo6tiHYOoi7eai+EKpTwEow95tVpbRia8oeWOamzsLRP2ZhtQnuLIaknANBQl4ZszybQzLm6WV0/fsXaewPk5afSkSB5aZl8jpKQgDxILKc6sGLKjBNkOkr+iOC+sjoeDvWzTLZt6LOy1Sq4xO8qyDriqMD2GAhoGQl6kc0WtR7XfuifsWXB5iXOk+ZnTSSv9k7tEpXOf93tutv+9VNibItuNHVbprr5AWha58OcjF8r7baIT9NMXlnHHt6Pj+eRW2JGDX87pTvq3g0iCthe8U0R blabla
```

Notice the whitespace at the start :)

So the key is not valid. I don't know if I am doing something wrong or there is a bug here. Please let me know what you think.

Also, what I would really like to be able to do is something like this:

```ruby
admin_repo = Gitolite::GitoliteAdmin.new("gitolite-admin")

admin_repo.add_key_from_string(key, 'mike')

admin_repo.save_and_apply
```

Thanks!