CURL is a mighty tool for transfering data to URLS. It supports a wide range of protocols.

Lets have a closer look on some handy snippets for daily work on the commandline:

Fetching content from a URL

When a page redirects to another location (the respondet http-status is somewhat 3xx)
curl can follow the redirection with the -L (- -location) flag.

Want to see what the request and response headers like?
It’s as simple as using the -v (- -verbose) flag.

For POSTing data to an URL u can use the parameter -d (- -data) .

You want to upload a file (image.jpg is located in the folder from where you run this command) to a php-script running at localhost/upload.php:

a upload-script for taking the uploaded file and store it in a file – the filename is the current timestamp – looks like this:

This is for windows using the cmd. Parsing a folder recursively for all pdf files and send them as a POST request to a certain URI:

 

Introduction – learn some words

This explanations are meant for Linux-Systems. Well, before we dive into ssh, its time to learn some vocabulary. Let’s learn some common files related to ssh issues. Usually, you have a folder ~/.ssh in your home directory (the Tilde „~“ before the .ssh directory is a shell replacement for your home directory). Here you can find files like:

authorized_keys
this file contains all the public keys you own from others. Compare the format of the content inside authorized_keys and compare it with the format of your id_rsa.pub key

id_rsa and id_rsa.pub
after creating a keypair (ssh-keygen) you get a private-key (which is by default stored in ~/.ssh/id_rsa) and a public-key (which lives in ~/.ssh/id_rsa.pub). Your private-key is for you alone, your public-key goes public. Private keys can have no extension but also have a .pem extension. There are also .ppk private-keys, these are created from the windows-ssh tool putty. A private key looks somethoing like:

whereas a public key looks like:

known_hosts
here are all servers stored that had already an established connection before.

config
with the file ~/.ssh/config you have a very handy config place to make ssh logins much easier. Check „man ssh_config“ for further information. If the config file does not exist you simply can create it.
Push your public-key to a server you want to communicate with:

 

Lets practice some commands

 

check details for a https certified website from the shell:

 

OpenSSL is a open-source version of the SSL/TLS-protocol

create a private key, a certificate signature request and a self signed certificate
create server.key

create .pem file

create server.csr (certificate signature request)

create unsigned certificate for 1 year

 

check if private-key fits to a certificate
you need to compare the hash-value of the certificate against the hash-value of the private-key

get the certificates hash-value

get the private-keys hash-value

 

remove passphrase from private key

 

rename certificate postfix cer to crt
you can just rename the file

Veröffentlicht unter ssh.

ImageMagic is the tool of choice when you have to manipulate images on the command line.

 

You can easily install it from a shell with the following command:

Change all images in the current folder to a with of 800 pixels with a quality of 80%:

Convert a *.gif image to a *.jpg image