SSH keys allow authentication between two hosts without the need of a password. SSH key authentication uses two keys, a private key and a public key. To generate the keys, from a terminal prompt enter:
# ssh-keygen -b 4096 -t rsaThis will generate the keys using the Ron Rivest, Adi Shamir, and Leonard Adleman (RSA) method. During the process you will be prompted for a password. Simply hit Enter when prompted to create the key.
Now copy the id_dsa.pub file to the remote host and append it to ~/.ssh/authorized_keys by entering:
# ssh-copy-id username@remotehostFinally, double check the permissions on the authorized_keys file, only the authenticated user should have read and write permissions. If the permissions are not correct change them with:
# chmod 600 ~/.ssh/authorized_keysUse the following command to list all active listening ports on a Linux system:
# sudo netstat -lnptu
-l = Show only listening sockets. (These are omitted by default.)
-n = Show numerical addresses instead of trying to determine symbolic host, port or user names.
-p = Show the PID and name of the program to which each socket belongs.
-t = TCP
-u = UDP
Start a Service:
# sudo service servicename startStop a Service:
# sudo service servicename stopList all Services:
# sudo service --status-allAdd Service to Default Runlevels:
# sudo update-rc.d servicename defaultsRemove Service from Default Runlevels:
# rm /etc/rc*/*servicenameYou've probably seen the 'flags:' field when using dig to query a nameserver. Curious to know what those flags actually mean? I know I was!
QR - Query/Response: This essentially indicates that a query was performed, and a response was given by the server.So you've noticed that swap space is allocated in your system monitor (top, htop, etc...), but is the machine actively swapping in/out? Run the following command and pay attention to the si (swapin) and so (swapout) columns:
# vmstat 1The machine is swapping if those numbers aren't continuously 0.
OK, there are a shit load of old files taking up space in some direcory on your Linux machine, and you want to do some housekeeping!
# sudo find /some/directory/ -type f -mmin +60 -exec rm {} \;The above command will delete all files in /some/directory/ that were last modified over 60 minutes ago. There is also a -mtime option that will let you specifiy days as opposed to minutes.
This simple method allows you to encrypt individual files using AES 256.
Encrypt:
# openssl aes-256-cbc -a -salt -in secrets.txt -out secrets.txt.encDecrypt:
# openssl aes-256-cbc -d -a -in secrets.txt.enc -out secrets.txtDecrypt by piping the encrypted output to OpenSSL:
# echo U2FsdGVkX1+bGeaQYNAnqFPX6W3pwMjVrGAkMDDUeDQ= | openssl aes-256-cbc -d -aOne example of how to add a new MySQL Database and apply user privileges from the command line.
mysql> CREATE DATABASE supercooldatabasename;