Skip to content

Instantly share code, notes, and snippets.

@thstarshine
Created October 21, 2017 09:40
Show Gist options
  • Save thstarshine/0fcfe407de1551e4db415ff249b2c9f3 to your computer and use it in GitHub Desktop.
Save thstarshine/0fcfe407de1551e4db415ff249b2c9f3 to your computer and use it in GitHub Desktop.
replace ssh authorized_keys by sed
#!/bin/bash
export NEW_SSH_KEY=ssh-rsa\ ....\ user@host
sed -e "s#ssh-rsa.*OLD_KEY_ID#$NEW_SSH_KEY#" ~/.ssh/authorized_keys
# ssh root@host 'bash -s' < this_script.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment