Wednesday, January 18, 2017

Install mod_wsgi with Apache on Centos 7

Install mod_wsgi 
(as root)
# yum install mod_wsgi
Now Edit the Apache configuration file to load the module
vi /etc/httpd/conf/httpd.conf
add the line (after the commented LoadModule example)
LoadModule wsgi_module modules/mod_wsgi.so

apachectl restart
or
systemctl restart httpd

Install Apache on Centos7

[root@hpcentos wb003c]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.pdx.edu
 * epel: linux.mirrors.es.net
 * extras: mirror.pac-12.org
 * updates: mirror.supremebytes.com
Package httpd-2.4.6-45.el7.centos.x86_64 already installed and latest version
Nothing to do

[root@hpcentos wb003c]# systemctl start httpd
[root@hpcentos wb003c]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

[root@hpcentos wb003c]# firewall-cmd --add-service=http --permanent
success

[root@hpcentos wb003c]# firewall-cmd --reload
success

[root@hpcentos wb003c]#

Installing Django on Centos 7

Run below commands as root or sudo.  Root # prompt shown below.

# yum install epel-release

# yum install python34

# yum install python3-pip

# pip3 install --upgrade pip

# pip3 install virtualenv

As normal user

$ virtualenv --python=`which python3` ~/.virtualenvs/djangodev


Now close django.git in your git hub account.

then

git clone git@github.com:rakeshrp/django.git

where rakeshrp is my github user.


Now to install Django

(djangodev) [wb003c@hpcentos ~]$ pip3 install -e ./django/
Obtaining file:///home/wb003c/django
Collecting pytz (from Django==2.0.dev20170118203328)
  Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
    100% |████████████████████████████████| 491kB 2.2MB/s
Installing collected packages: pytz, Django
  Running setup.py develop for Django
Successfully installed Django pytz-2016.10
(djangodev) [wb003c@hpcentos ~]$


Run some tests

$ cd django/tests
$ ./runtests.py



Happy Web development :)




Monday, January 9, 2017

Multihop SSH with Putty and Socks5 Proxy

Requirement:
I wanted to access a server (Centos 7 on port 22421) at home behind a pfsense firewall and I was at work.
The pfsense firewall allowed traffic from an intermediate host but not from my machine at work.
The pfsense firewall was setup to allow traffic from my intermediate host with public key authentication
From work I could ssh to the intermediate host.
To access the pfsense GUI I had to use a browser and do a SOCKS5 proxy to the intermediate host and I wanted to setup a multihop ssh with putty to intermediate host and then to my home server.

I was able to setup SOCKS5 proxy and multihop ssh in putty in a single putty connection configuration.

I use a dynamic DNS to map a hostname to my dynamic IP provided by my ISP.
I have already done the step of port forwarding any SSH request that come on the ISP provided modem/router to my Centos 7 server.


  1. Start putty and on the “Session” page of the “Putty Configuration Dialog” that appears, fill in the host name and user name  for the final destination host (my Centos 7 server and port 22421). 
  2. Switch to the Connection –> Proxy page, select “Local” as the proxy type enter the following as the local proxy command: plink.exe intermediate.proxy.host -l username -agent -nc %host:%port
  3. go to Connection -> data and set the auto-login username 
  4. go to Connection -> SSH -> tunnels and setup dynamic port forwarding   Select Destination as Dynamic, source port as any number greater than 1024 , In my case i set it to 7002 in Source port field.         Click on ADD
  5. Save the session.


Now in Firefox setup Socks5 proxy


In Firefox Settings -> Options -> advanced -> Network settings -> Manual Proxy configurations 
Select SOCKS host as localhost , enter port as 7002 , choose Socks v5 radio button 
Click OK,


Now use putty to open the connection setup earlier and then in Firefox url type the url for Pfsense (In my case it was 10.0.0.1 ) and Viola my pfsense login screen comes up, 



partial source : http://mikelococo.com/2008/01/multihop-ssh/  for multihop through Putty.

Followers

About Me

Torrance, CA, United States