partenaire

dimanche 5 février 2012

How To Setup A Linux PC Card Server

Hi guys, I've wanted to do this for a while and have finally got round to making it happen. Since buying my enormouse 24" iMAC my old ASUS pc has been sat on the bench in the garage doing nothing. Well now it has a very important job. It now runs flawlessly serving my little white card around my house and beyond.

How to setup a Linux PC Card Server.

Prerequisites :-

1. A networked PC that has no real purpose in life.
2. A clean install of ubuntu desktop edition. ( _http://www.ubuntu.com/GetUbuntu/download )
3. Configured telnet access to ubuntu.
4. Configured FTP server on ubuntu.
5. Omnikey 3121 USB card reader. ( _http://www.omnikey.com )
6. 1 - 2 spare hours.



I'm not going into the initial setup of Ubuntu , telnet or FTP as there are many places you can find help with that. Its dead easy !

At this point I should mention that much of this setup is done using command line instructions, in my case executed from my mac via telnet. You can of course use putty in windows or do it locally on the ubuntu machine in a terminal window. I wll not stipulate the difference between these options, thats up to you.




Required Software :-

NewCS
CCcam
PCSCd
pcsc-tools
Omnikey Driver

To install the required components simply type the following, enter your password and answer the prompt with 'yes'

sudo apt-get install pcscd
sudo apt-get install pcsc-tools


Omnikey Driver
_http://www.omnikey.com/index.php?id=69&rName=CardMan%203x21%20PC/SC%20CCID%20for%20Linux%2032%20Bit&did=69

This is a tarball I believe they're known as, its an archive basically, I unpacked it on my mac and then just FTP'd the unpacked folder to the ubuntu desktop. You can use Winrar also to unpack it or I'm sure there's a way in linux too.

Again in telnet, navigate to the unpacked folder and install by typing

./install

Once you have everything installed you can test the card reader for a response. Simply type

pcsc_scan


Code:
b16mcc@b16mcc-desktop:~$ pcsc_scan
PC/SC device scanner
V 1.4.14 (c) 2001-2008, Ludovic Rousseau <ludovic.rousseau@free.fr>
Compiled with PC/SC lite version: 1.4.99
Scanning present readers
0: OmniKey CardMan 3121 00 00
If your card is not in the database it tells you the command to use to update that database. I needed to do that and afterwards it knew my card. This is not essential however for it to work, just nice to see !

Code:
Possibly identified card (using /home/b16mcc/.smartcard_list.txt):
3F FD 13 25 02 50 00 0F 33 B0 0F 69 FF 4A 50 D0 00 00 53 59 02
 Sky Digital (DSS satellite TV card) 2009 issue
Install and setup NewCS.
Ok so via FTP lets setup some files and folders. By default the home directory of your FTP server will be /home/username/

In that folder I made a new folder, NewCS. I did this using my FTP software.
Now lets put the files we need in those folders.

Sticking with just NewCS for now, we'll add CCcam later.
In /home/username/NewCS you need :-
newcs.i686.pcsc
newcs.xml

If you like you can now rename your newcs.i686.pcsc , I called it newcs_167

Ok, next we need to edit the newcs.xml file to read our card using our Omnikey reader. Here's my config with a few personal details removed. This is exactly my config it does work.

Code:
<newCSconfig>
 <readers name="Standard Omnikey on PC">
  <device>
   <name>Omnikey</name>
   <type>pcsc</type>
   <mhz>368</mhz>
   <node>0</node>
   <parity>odd</parity>
   <reset>normal</reset>
   <export>Yes</export>
   <enabled>Yes</enabled>
   <boxkey>01020304</boxkey>
   <blocksa>No</blocksa>
   <blockua>No</blockua>
   <blockga>Yes</blockga>
   <blockC0>Yes</blockC0>
   <carddetect>Yes</carddetect>
   <newcamd_port>12010</newcamd_port>
   <autosid>Yes</autosid>
   <priority>round</priority>
  </device>
 </readers>
 <radegastserver>
   <enabled>No</enabled>
   <port>10001</port>
   <allow>
    <hostname>localhost</hostname>
   </allow>
 </radegastserver>
 <cache>
   <emm>20</emm>
   <ecm>-1</ecm>
 </cache>
 <httpd>
  <server>
   <port>8080</port>
   <enabled>yes</enabled>
  </server>
  <user>
   <name>admin</name>
   <password>admin</password>
   <accesslevel>admin</accesslevel>
  </user>
 </httpd>
 <debug>
   <password>NewCSpwd</password>
   <mode>simple</mode>
   <level>internal</level>
   <type>all</type>
   <output>console,tcp</output>
   <tcp_port>1001</tcp_port>
   <tcp_options>normal,init</tcp_options>
 </debug>
 <newcamdserver>
   <enabled>Yes</enabled>
   <name>newcs</name>
   <deskey>01 02 03 04 05 06 07 08 09 10 11 12 13 14</deskey>
   <user>
    <name>CCcam</name>
    <password>CCcam</password>
    <au>on</au>
    <sidoverride>off</sidoverride>
    <spider>No</spider>
                                <cardlevel>1</cardlevel>
   </user>
 </newcamdserver>

</newCSconfig>
Once thats in place and we're happy we've had a good output from pscs_scan we can go ahead and run NewCS for the first time. Just one more thing though, NewCS has a default location where it expects to see the newcs.xml file, we of course are using a custom location so we need to tell it that. Run NewCs by typing this :-

./newcs_167 -C /home/username/NewCS/newcs.xml

The -C switch simply means use this location for the config. You can see all switches by using -h for help.

So, thats it she's running. You should now be able to open up the web browser and see your card. In your address bar type in :-

_http://dreamboxip:8080

Enter your user name and password and you're in. Have a click around the different options on the left and you should see your card.

To stop NewCS simply type in your telnet session :-

killall newcs_167

Now, its a little long winded typing that startup command with the great big -C switch so we'll make a tiny script file to do it for us.

Code:
#!/bin/bash
cd /home/username/NewCS
./newcs_167 -C /home/username/NewCS/newcs.xml
Save this file as startnewcs.sh in your /home/username folder

Now to start NewCS you can simply type :-

./startnewcs.sh

This is a very very simply way of doing it, but it works. If someone out there is a linux god then maybe you can retort here and show us how its done properly. Cheers.....

So now that the server is up and running lets connect to it from CCcam. Simply add this line to the CCcam.cfg in your Dreambox.
Code:
N: 192.168.100.100 12010 CCcam CCcam 01 02 03 04 05 06 07 08 09 10 11 12 13 14
Where 192.168.100.100 is the IP address of your new linux server.
You'll notice the port number 12010 matches with the <newcamd_port> parameter and the user and pass match with the <users> parameters.

As normal if you want to access this from outside your LAN then you'll need to forward port 12010 in your router to the Linux PC IP address and replace the IP address in the N: line with your WAN IP or your DNS address.

Ok so that enough for now, I'm going bog eyed. Oh just one thing, all the files and folders we have FTP'd or created, just make sure you CHMOD them all to 755 to ensure they have the correct permissions. Things can be a little confusing when you don't do this.

Guys, some of this I've done from memory so if there's anything thats troubling you I'm sure you'll comment and I'll be happy to help.

I'm pretty sure you can setup the CCcam server too using this basis but if anyone wants it adding to this tutorial then please ask and I'll oblige.

Aucun commentaire:

Enregistrer un commentaire