Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Last active October 14, 2019 17:40
Show Gist options
  • Save xeoncross/358d7f06f5c22e6382a7bb4e97a58dfc to your computer and use it in GitHub Desktop.
Save xeoncross/358d7f06f5c22e6382a7bb4e97a58dfc to your computer and use it in GitHub Desktop.
Simple SSH user for read-only access to MySQL. Note, they still have a home directory and full SSH access so this assumes you trust them and/or need them to have access to other system features.
# Create the SSH/system user
useradd dbreports
mkdir -p /home/dbreports/.ssh
chown -R dbreports:dbreports /home/dbreports/
chmod 700 /home/dbreports/.ssh
# Add the SSH keys
vim /home/dbreports/.ssh/authorized_keys
chmod 644 .ssh/authorized_keys
# Add this user to
mysql
> GRANT SELECT ON *.* TO 'dbreports'@'localhost' IDENTIFIED BY 'passwordhere';
> flush privileges;
> quit;
# You might want to replace `localhost` with `%` depending on access
# Test it out
mysql -u dbreports -p
@xeoncross
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment