NO Authentication:
wget http://website.com/get/articles
With Basic Authentication:
wget --user=username --password=password http://website.com/get/articles
Step 1: Check for SSH keys:
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
Step 2: Generate a new SSH key:
$ ssh-keygen -t rsa
# Generating public/private rsa key pair.
You can press enter here, saving the file to the user home
Enter file in which to save the key (/home/username/.ssh/id_rsa):
It's up to you whether you want to use a passphrase. Entering a passphrase does have its benefits: the security of a key, no matter how encrypted, still depends on the fact that it is not visible to anyone else. Should a passphrase-protected private key fall into an unauthorized users possession, they will be unable to log in to its associated accounts until they figure out the passphrase, buying the hacked user some extra time. The only downside, of course, to having a passphrase, is then having to type it in each time you use the Key Pair.
Enter passphrase (empty for no passphrase):
The public key is now located in /home/username/.ssh/id_rsa.pub The private key (identification) is now located in /home/username/.ssh/id_rsa
Stopwatch format:
date1=`date +%s`; while true; do
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
done
Countdown timer:
seconds=20; date1=$((`date +%s` + $seconds));
while [ "$date1" -ne `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r";
done
You can combine these into simple commands by using bash (or whichever shell you prefer) functions. In bash, add these lines to your ~/.bashrc (the sleep 0.1 will make the system wait for 1/10th of a second between each run so you don't spam your CPU):
function countdown(){
date1=$((`date +%s` + $1));
while [ "$date1" -ne `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S)\r";
sleep 0.1
done
}
function stopwatch(){
date1=`date +%s`;
while true; do
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 0.1
done
}
You can then start a countdown timer of one minute by running:
countdown 60
You can countdown two hours with:
countdown $((2*60*60))
or a whole day using:
countdown $((24*60*60))
And start the stopwatch by running:
stopwatch
During a recent client project, I frequently needed to access a remote database table and update the same for certain fields. This was accomplished using phpMyAdmin on the server. However, it was getting tedious and was prone to accidental updates and deletes. Also, a couple of other developers also needed to make changes to certain fields on the remote database from their local server.
This is all a tedious process and prone to errors. One solution was to create a quick REST api wrapper around the remote database, using which developers could update the database table without any risk of corrupting the data and also with the added benefit of updating the table programmatically.
This post shows how to create a simple REST API using Slim framework. Slim is a PHP micro framework which lets you write quick PHP web applications. Here we will use it to build a REST api. Although I cannot show the exact database schema used, as this would not make sense without the context, I’ve provided a simple schema for the examples. The schema shows a students table which provides student scores along with their names.
Simple TLS/SSL nodejs server example
Transport Layer Security (or TSL) is the successor to Secure Sockets Layer (or SSL). It, along with SSL, are the de-facto standard cryptographic protocols for secure communications over the web. TSL encrypts communications on top of a network transport layer (typically tcp), and uses public-key cryptography to encrypt messages.
In public-key cryptography, each peer has two keys: A public key, and a private key. The public key is shared with everyone, and the private key is (naturally) kept secret. In order to encrypt a message, a computer requires its private key and the recipient's public key. Then, in order to decrypt the message, the recipient requires its own private key and the sender's public key.
In TLS connections, the public key is called a certificate. This is because it's "signed" to prove that the public key belongs to its owner. TLS certificates may either be signed by a third-party certificate authority (CA), or they may be self-signed. In the case of Certificate Authorities, Mozilla keeps a list of trusted root CAs that are generally agreed upon by most web browsers. These root CAs may then issue certificates to other signing authorities, which in turn sign certificates for the general public.
TLS support in node is relatively new. The first stable version of node.js to support TSL and HTTPS was the v0.4 branch, which was released in early 2011. Since then, the primary focus of the core developers has shifted from TLS/HTTPS to Windows support in the v0.5 branch. As such, the TSL APIs in node are still a little rough around the edges, and documentation leaves something to be desired.