Subject: | key2nodes path to not insert already existing public keys |
key2nodes add multiple rows of the same key if the key is already presents.
With this path the script check if the key is already interted:
root@test:~# diff /usr/local/bin/key2nodes /usr/local/bin/key2nodes.ORIGINAL
165,182c165
< }, q{
< read PUBLIC_KEY
< if [ ! -d ~/.ssh ]
< then
< mkdir ~/.ssh
< chmod 700 ~/.ssh
< fi
< if [ ! -f ~/.ssh/authorized_keys ]
< then
< touch ~/.ssh/authorized_keys
< chmod 640 ~/.ssh/authorized_keys
< fi
< if [ -z "$(grep "$PUBLIC_KEY" ~/.ssh/authorized_keys)" ]
< then
< echo $PUBLIC_KEY >> ~/.ssh/authorized_keys
< fi
< });
<
---
Show quoted text
> }, }, 'if [ ! -d ~/.ssh ]; then mkdir ~/.ssh; fi; chmod 700 ~/.ssh; cat >> ~/.ssh/authorized_keys && chmod 640 ~/.ssh/authorized_keys');
root@test:~#