Archive for the ‘Ubuntu Linux’ Category

Configure pptpd vpn with ms-chapv2 and mppe on Ubuntu

Monday, April 2nd, 2007

We’ve installed a NAT+VPN to get rid of Microsoft’s one, and implemented the same functionality with PoPToP version 1.3.0.

The necessary settings are the following:

1) try if you have the necessary kernel modules (in Ubuntu 6.10, all is included. if you don’t have them, you’re doomed - you need to re-compile your kernel)

modprobe ppp_mppe
modprobe ip_gre

if the reply is the well known unix’s golden silence, you need to add the modules to /etc/modules:

ppp_mppe
ip_gre

to have it loaded, and reboot.

2) Install pptpd

apt-get install pptpd

3) in /etc/pptpd.conf, have the following:

option /etc/ppp/options.pptpd
speed 115200
localip 10.1.1.10 #our eth0
remoteip 10.1.1.228-238 #our ip stack
listen xx.xx.xx.250 #our eth1

4) change /etc/ppp/options to the following:

lock
noauth
refuse-eap
refuse-chap
refuse-mschap
nobsdcomp
nodeflate
require-mppe-128

5) in /etc/ppp/pap-secrets, don’t forget to add the blank user and password
* *

4) use the following settings in /etc/ppp/options.pptp:

lock
name pptpd
proxyarp
asyncmap 0
-chap
-mschap
+mschap-v2
require-mppe
lcp-echo-failure 30
lcp-echo-interval 5
ipcp-accept-local
ipcp-accept-remote

This setup will work with any Windows 2000/XP client, and all pptp configs on Linuxes. (with regards to http://poptop.sourceforge.net/dox/radius_mysql.html)

Enjoy ;)


Install XServer and Xfce4 on Ubuntu Server

Monday, April 2nd, 2007

I just wanted to have a nice GUI on a test environment, so without getting 200 megabytes for xubuntu-desktop or 524 megabytes for ubuntu-desktop, I simply installed the following:


apt-get install xserver-xorg
apt-get install xfce4

with these packages - only about 40 megabytes to download - you’ll have a clean and working desktop.
I found some errors, possibly because I previously installed X.org, that I needed to

ln /usr/X11/Xorg -> /etc/X11/X

first, then

sudo Xorg -configure

to let it happen:)

NOTE: *make sure to have a mouse and a keyboard attached* or this setup will be broken.
Of course, you can enter

Option "AllowMouseOpenFail" "1"

into your xorg.conf > Section “ServerLayout”

If you too configure it via ssh and start X by error, and see the .XAthority file locked error, type:

xauth -b quit


WinSCP + RemotelyAnywhere’s SSH server + other drives than C:

Thursday, March 29th, 2007

Well, if you want to use another drive than C: with the above config, open WinSCP (I use the FAR plugin) and on the remote directory tab type in: /d/directory_you_want_to_use


OpenSSH and network drives on Windows

Monday, March 19th, 2007

I’m using OpenSSH 3.x on all servers both Windows and Linux / Unix and Macs as well to remotely access files and services. With OpenSSH for Windows I faced with the following error:


C:\unix\Console2>ssh servername.hu -l balint
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/cygdrive/x/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /cygdrive/x/.ssh/id_rsa
Enter passphrase for key '/cygdrive/x/.ssh/id_rsa':

This is of course not the way it should be - it should normaly authenticate with the keyfiles; however on Windows we don’t have chmod to change the permissions. It turned out, that NT rights are not successfuly loaded with Cygwin, if your files are on a network drive - and X: is a remote server for me.

So - instead of running unnecessary circles: we can change the CYGDRIVE and the CYGPATH variables (even temporarily) to check our .ssh folder on a local path:


set CYGDRIVE=c:
set CYGPATH=\unix

copy x:\.shh c:\unix\.shh

And voila:


C:\unix\Console2>ssh servername.hu -l balint
Last login: Mon Mar 19 17:11:58 2007 from xx.xx.xx.140
[balint@servername.hu ~]$


Create the ’service’ command on other linuxes

Wednesday, February 28th, 2007

#!/bin/sh

set -e

/etc/init.d/$1 $2 $3

I found this tip at linux-noob. Thanks!


Nslookup for Linux: dig

Tuesday, February 27th, 2007

I’ve recently found out on my Mac, that nslookup will be obsolete; and we need to use dig instead of this well known tool. If you want to install it on Fedora, just type:
apt-get install bind-utils


Mount an OS X shared folder on Linux

Thursday, February 22nd, 2007

Title says it all: mount -t nfs [mac's ip or name]:Users/Shared /mnt/[mountfolder]


Mono upgrade on a custom built Fedora Linux

Monday, February 27th, 2006

1) Grab the packages from http://www.mono-project.com/Downloads

2) Uninstall the packages in this given order:

rpm -e mod_mono
rpm -e xsp
rpm -e mono-data
rpm -e bytefx-data-mysql
rpm -e mono-winforms
rpm -e mono-web
rpm -e mono-data
rpm -e mono-locale-extras
rpm -e mono-core

3) install the same packages in reverse order by calling rpm -i


Fuck, Mono! CS2016: Code page ‘utf8′ is invalid or not installed

Friday, September 30th, 2005

You see the error as well when trying to migrate from a Mono.Net project to an MS.Net project?
The key is in the web.config file (one retard thinks he can change everything to make it more ‘compatible’):
< ?xml version="1.0" encoding="utf-8" ?>
<configuration>
[...]
<system .web>
<compilation defaultLanguage=”c#” debug=”true”>
<compilers>
<compiler language=”cs;c#;csharp” extension=”.cs” warningLevel=”1″ compilerOptions=”/codepage:65001″ type=”Microsoft.CSharp.CSharpCodeProvider, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ />
</compilers>
[..]
</compilation>
</system>
</configuration>

The codepage:utf8 is not valid, it must be a number: 65001. Or you can simply omit this whole line…


Guide: connect to an Oracle database with Oracle instant cient via unixODBC and Mono .net on Ubuntu

Wednesday, September 14th, 2005

Today I found a fascinating problem, how to manage an access to a remote Oracle database via dotnet and with a program written in C#. There are mainly two ways to connect to a database: using a pre-built SqlClient module, or to use the good old ODBC one.
Microsoft implemented the System.Data.OracleClient module for the ms.net framework, so did the Mono guys. However, this mono implementation is NOT managed code, so you can imagine. Oracle provided it’s own dotnet classes for the developers, but it mainly focuses on the 10x version, and it has no release for mono.
I have never managed Oracle before (just used in a huge application framework, but never developed on it), so first of all, I needed to figure out what tools do I need to create a connection. I found a cool RPM-based guide on the Oracle Technet.
You need to say apt-get install alien first, to be able to install RPMs on Ubuntu. Then you can grab and install the two files, i usually download them with wget.
I advise you to place the tnsnames.ora file directly under /etc, so it will always be on the path! To test it, type sqlplus scott/tiger@[the_server] I’ve installed the unixODBC package from the hoary universe, and to make it usable with Oracle, I’ve downloaded the proper Easysoft.com Oracle driver. It has a very nice install shell, and after it creates a text file with a machine number, you need to submit it via the website or email, and you’ll receive a licence id (you need to place it under /usr/local/easysoft/licences BUT you need to delete the LICD: chars… it took me 5 minutes to figure out :) Now you need to set the variables: ORACLE_HOME=/usr/lib/oracle/10.1.0.4/client
export ORACLE_HOME
LD_LIBRARY_PATH=/usr/lib/oracle/10.1.0.4/client/lib/
export LD_LIBRARY_PATH
(the best solution is to add these variables to the /etc/environment without the exports) if you get to this point, you can check the connection with the isql tool, located under /usr/local/easysoft/unixODBC/bin/: /usr/local/easysoft/unixODBC/bin/isql -v ORACLE (ORACLE is the DSN name in /etc/odbc.ini) It will reply with an sql shell, type: select * from scott.emp; to test it.

I advise you to always grab the latest mono, at the time of writing this is 1.1.9, I’ve installed it by selecting the Fedora RPM repository, downloading all necessary files with wget and aliened them. I used the following odbc.cs program to test the connection (updated go-mono.com example)
using System;
using System.Data;
using System.Data.Odbc;
class OracleTest2 {
public static void Main() {
string connectionString = "DSN=ORACLE;UID=scott;PWD=tiger";
IDbConnection dbcon = new OdbcConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
string sql = "SELECT ename, job FROM scott.emp";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string EmpName = (string) reader["ename"];
string EmpJob = (string) reader["job"];
Console.WriteLine(”EmpName: ” + EmpName + ” Job: ” + EmpJob);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}

To compile and run, say:
mcs odbc.cs -r:System.Data.dll
mono odbc.exe
…and you can see the final results :)