Skip to content

Instantly share code, notes, and snippets.

@lanefu
Last active July 23, 2023 04:38
Show Gist options
  • Save lanefu/9bf767f7721d9bbb2d64d2437fc97a2a to your computer and use it in GitHub Desktop.
Save lanefu/9bf767f7721d9bbb2d64d2437fc97a2a to your computer and use it in GitHub Desktop.
another ssh public key script
#!/bin/bash
NEW_USER="someuser"
USER_PUBLIC_KEY="some public key"
mkdir -p /home/${NEW_USER}/.ssh
echo "${NEW_USER_PUBLIC_KEY}" >> /home/${NEW_USER}/authorized_keys
chown -R ${NEW_USER} /home/${NEW_USER}/.ssh
chmod 700 /home/${NEW_USER}/.ssh/
chmod 600 /home/${NEW_USER}/.ssh/authorized_keys
echo "key installied"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment