Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, March 24, 2013

Setup chroot jail for ssh / sftp in Ubuntu

Using Ubuntu 10.04.2 LTS.

Step by step:

Read here for more complete and original information (thanks for the script).

Or follow instruction below:

You must be root.

Get the script from the above link:
# cd /usr/local/sbin
# wget http://www.fuschlberger.net/programs/ssh-scp-sftp-chroot-jail/make_chroot_jail.sh
# chmod 700 /usr/local/sbin/make_chroot_jail.sh


Edit the script (make_chroot_jail.sh):
# vi /usr/local/sbin/make_chroot_jail.sh
change first line, from:
#!/bin/sh
into:
#!/bin/bash
because it will be error if we use sh on Ubuntu 10.04.2 LTS.
Then add line after these below:
[...]
else
  APPS="/bin/bash /bin/cp /usr/bin/dircolors /bin/ls /bin/mkdir /bin/mv /bin/rm /bin/rmdir /bin/sh /bin/su /usr/bin/groups /usr/bin/id /usr/bin/rsync /usr/bin/ssh /usr/bin/scp /usr/sbin/unix_chkpwd"
fi


Add this line below, some program that we might want to add to the APPS variable:
APPS+=" /bin/cat /usr/bin/vi"
The /bin/cat is mandatory since .bashrc using it.

Create jail directory:
# mkdir /path/to/jail

Create will be jailed user account:
# adduser jailed_username

Run the script:
# make_chroot_jail.sh jailed_username /bin/bash /path/to/jail
Edit sshd_config:
# vi /etc/ssh/sshd_config
Change from:
Subsystem sftp /usr/lib/openssh/sftp-server
into:

Subsystem sftp internal-sftp 
And add these to the end of the file:
Match User jailed_username
   ChrootDirectory /path/to/jail
   AllowTCPForwarding no
   X11Forwarding no

Restart sshd:
# /etc/init.d/ssh restart

We need to edit /etc/passwd and change from:
jailed_username:x:1001:1001:,,,:/path/to/jail/home/jailed_username:/bin/bash
into:
jailed_username:x:1001:1001:,,,:/home/jailed_username:/bin/bash
because it will not see /path/to/jail anymore, but /

Finish.

Tuesday, March 1, 2011

How to run process in background then logout

In linux, if you want to run a process in the background without stopping when you logout then you can do it with this command:

# nohup [program_name] [arguments] &

Don't forget the ampersand.

Wednesday, February 9, 2011

How to setup unoconv in Ubuntu Lucid

If you want to convert between any document format that OpenOffice understands especially for non-interactive conversion of documents.

You will need openoffice.org:
# apt-get install openoffice.org
# apt-get install openoffice.org-writer2latex

Install unoconv:
# apt-get install unoconv

Running unoconv:
# unoconv --listener &

Test:
# unoconv -f pdf myfile.ppt

Done.

Monday, February 7, 2011

How to set up tesseract-ocr from Google

You need the following library (Ubuntu):

# apt-get install libpng12-dev
# apt-get install libjpeg62-dev
# apt-get install libtiff4-dev
# apt-get install zlib1g-dev

Set up leptonica:

# wget http://www.leptonica.com/source/leptonlib-1.67.tar.gz
# tar xfz leptonlib-1.67.tar.gz
# cd leptonlib-1.67
# ./configure
# make
# make install

Setup tesseract-ocr (version 3.0):

# svn checkout http://tesseract-ocr.googlecode.com/svn/trunk/ tesseract
# cd tesseract
# ./configure
# make
# make install
# ldconfig -v

Testing tesseract-ocr:

# tesseract eurotext.tiff result

Check result:

# cat result.txt

Done.

How to set up or adding alias to network interface in Ubuntu

Edit /etc/network/interfaces:

# vi /etc/network/interfaces

Append text below:

auto eth0:1
iface eth0:1 inet static
address 192.168.1.7
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0

Restart networking:

# /etc/init.d/networking restart