Browse Source

ssh: fix storing of old keys on sync

Signed-off-by: Alejandro Mery <amery@geeks.cl>
master
Alejandro Mery 1 year ago
parent
commit
a4b8a47507
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      sync_ssh.sh

+ 6
- 4
sync_ssh.sh

@ -1,7 +1,9 @@
#!/bin/sh
SSHDIR="$HOME/.ssh"
keys=
for x in $HOME/.ssh/*.pub; do
for x in $SSHDIR/*.pub; do
if [ -s "$x" ]; then
keys="$keys $x"
else
@ -9,7 +11,7 @@ for x in $HOME/.ssh/*.pub; do
fi
done
ak="$HOME/.ssh/authorized_keys"
ak="$SSHDIR/authorized_keys"
if [ -s "$ak" ]; then
while read l; do
found=
@ -25,7 +27,7 @@ if [ -s "$ak" ]; then
if [ -z "$found" ]; then
name="$(echo "$l" | cut -d' ' -f3)"
if [ -n "$name" ]; then
echo "$l" > .ssh/$name.pub
echo "$l" > "$SSHDIR/$name.pub"
fi
fi
done < $ak > $ak~
@ -34,7 +36,7 @@ else
for x in amery@geeks.cl \
amery@builder.geeks.cl \
amery@shell.easy-cloud.net; do
x="$HOME/.ssh/$x.pub"
x="$SSHDIR/$x.pub"
[ -s "$x" ] || continue
cat "$x"
done > $ak~

Loading…
Cancel
Save