This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl s_client -showcerts -connect mail.nixcraft.net:443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo -u postgres psql | |
postgres=# create user myuser with encrypted password 'myfuser'; | |
postgres=# grant all privileges on database yourfdatabasename to myfuser; | |
postgres=# GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO myfuser; | |
postgres=# alter default privileges in schema public | |
grant SELECT, INSERT, UPDATE, DELETE on tables to liman; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install s3cmd | |
# config s3cmd first with s3cmd --configure | |
# run mkdir /backup/mysql_dump/logs -p | |
#!/bin/bash | |
#I use this to create a little bash script that will backup the database at regular intervals, and I’ll even chuck in deleting backups older than 15 days and move the dump_file in S3_bucket. | |
#create a few variables to contain the Database_credentials. | |
# Database credentials | |
USER="root" | |
PASSWORD="root" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install s3cmd | |
# config s3cmd first with s3cmd --configure | |
# run mkdir /backup/postgres_dump/logs -p | |
#!/bin/bash | |
#I use this to create a little bash script that will backup the database at regular intervals, and I’ll even chuck in deleting backups older than 15 days and move the dump_file in S3_bucket. | |
#create a few variables to contain the Database_credentials. | |
# Database credentials | |
DB_NAME="mypostgresdbname" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\connect your_database; | |
REVOKE ALL ON DATABASE your_database FROM yourf_name; | |
GRANT CONNECT ON DATABASE your_database TO yourf_name; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO yourf_name; | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO yourf_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. To create a new user in PostgreSQL: | |
CREATE USER username WITH ENCRYPTED PASSWORD 'your_password'; | |
#2. GRANT the CONNECT access: | |
GRANT CONNECT ON DATABASE database_name TO username; | |
#3. Then GRANT USAGE on schema: | |
GRANT USAGE ON SCHEMA schema_name TO username; | |
#4. GRANT SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#netstat -nlpt | |
===================== | |
example output | |
===================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#netstat -nputw | |
===================== | |
example output | |
===================== | |
Active Internet connections (w/o servers) | |
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#netstat -ntu|awk '{print $5}'|cut -d: -f1 -s|sort|uniq -c|sort -nk1 -r | |
============================= | |
example output | |
============================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geo $whitelist_ip { | |
default 1; | |
# Your office ip | |
127.0.0.1/32 0; | |
} | |
map $whitelist_ip $default_limit { | |
1 $binary_remote_addr; | |
0 ""; |