Category Archives: Ubuntu

SSH X11 Forwarding Display using MobaXterm on Windows

Overview

SSH X11 Forwarding Display is a tricky thing to establish on different Windows operating systems.
MobaXterm is a free Xserver and tabbed SSH client for Windows Operating Systems which allows you to run native Linux Applications like they are running on your Windows.
Continue reading

Tutorial: Your first WSGI Python web application served on Apache HTTPd.

Abstract

We’ll create a new python project using wsgi (web server gateway interface)

 

Introduction

Python based web applications can be served in several ways. You can use the old and good CGI interface, or use the more common used mod_python. FastCGI and SCGI are also an option. but most of those ways supports the WSGI interface which is the recommended way. You can learn more about each way, and the cons and pros of each, and what is wsgi  in this great tutorial/article: How to use python in the web.

We’ll build a skeleton for a Python based WSGI web application hosted on Apache HTTPd. I’ve choosed WSGI over other methods to promote web application portability across a variety of web servers.

 

Prerequisities

  • Python
  • Apache HTTPd Service running and working. trim instance is better.

 

Setup

mod_wsgi

red-hat/fedora/centos: install mod_wsgi using:

yum install mod_wsgi

debain/ubuntu: install mod_wsgi using:

apt-get install mod_wsgi

 

Virtual Application

configure your httpd with:

1
2
3
4
5
WSGIScriptAlias /myapp /var/www/myapp/myapp.wsgi
<Directory /var/www/myapp>
   Order allow,deny
   Allow from all
</Directory>
WSGIScriptAlias /myapp /var/www/myapp/myapp.wsgi
<Directory /var/www/myapp>
   Order allow,deny
   Allow from all
</Directory>

 

WSGI

Create the file myapp.wsgi at ‘/var/www/myapp’ and fill it with the example from mod_wsgi documentation:

1
2
3
4
5
6
7
8
9
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'
 
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
 
    return [output]
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

You may need to restart your apache using: service httpd restart.

Now use your browser to see the ‘Hello World’ response from your first wsgi server.

Helloworld

 

More information

 

Happy wsgi python-ing…!

SSH connection without password between two linux machines

Overview

How to establish SSH connection without password between two linux/unix machines

SSH connection without password between two linux machines

Instructions

  1. Generate the files: [id_rsa], [id_rsa.pub] in the First Machine by typing at command (do not use a password – just hit Enter*) :
    ssh-keygen

    * You don’t want to enter any passwords, because you want to call ssh from a within a shell script.
    ** The randomart is an easier way for humans to validate keys.
  2. Copy (and rename) id_rsa.pub to authorized_keys on Server (run from the same computer you run ssh-keygen);
    scp -r -P 22 /root/.ssh/id_rsa.pub destination:/root/.ssh/authorized_keys<em>
    </em>

    Where destination is server B.

Now you can connect as root without a password between the servers.