Skip to content

Instantly share code, notes, and snippets.

@saderi
Last active April 19, 2021 13:18
Show Gist options
  • Save saderi/7b970d77ce3603cdff250d29bf2ab333 to your computer and use it in GitHub Desktop.
Save saderi/7b970d77ce3603cdff250d29bf2ab333 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Add my ssh-key to ubuntu root user and active ssh root login
# Login as root or run with sudo
# wget -qO - "https://saderi.com/goroot" | bash -
# OR
# curl -fsSL https://saderi.com/goroot | bash -
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
MY_SSH_KEY='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvtGaJ6KNDy+kmdFgmXnuq2AB86K+hHgARAiOsdka9Ofx7mYmoZdxuCKi/OhYf6enbC1CqFpB+iKaHXYBPYolJ9sNBzVZ9jpSZQ3/v6jP1CxlL7iTjm6Ty0IQjnmKazJfioMqZP/nwtalT/zioAtS7jG8WsUMaHHbMAKHIad13bS60QkflNzeesFIfLRMguqL3QTJhJNiRfMMUlOVgh1XD4xkO9+shl3xvZWibSE2cVhfDBsBlJfDcgi0FsaYrP2JPFinOXjVh8eSCQe1pta1H76Pff4kh14aiLOwmE+EblnjpfG0a3y4bPLzjqdHqS/Ik+q9S8AU2YqCJm3QfKIJz payam@saderi'
mkdir -p /root/.ssh
echo $MY_SSH_KEY >> /root/.ssh/authorized_keys
echo "Done"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment