2501

Stand Alone Complex

Subscribe to RSS feed

Posts tagged with "linux"

BACK IN BLACK! ARCH LINUX!

,

Finally! I got a Dell Dimension computer and decided to install Arch Linux.
Everything went smooth and I just need sometime to catch up with the latest.
So far, so good!
-2501

linux + belkin n300 usb adapter

,

from the ubuntu forums: http://ubuntuforums.org/showthread.php?t=1493320&highlight=n300

Nailed it using the Belkin N300 and a netgear wndr3700 router.

From the installation CD for the N300 nab the 3 XP files and put them in a folder on the home folder.

net8192su.cat
net8192su.inf
rtl8192su.sys

install and open the ndiswrapper tool
find the net8192su.inf file and install
plug in the usb wireless n300 and setup your wireless settings.

Had some issues initially with slow and intermittent service but turned to be that usb port was too close to other wires. moved it away to another usb port and it works rapido!!

Slackware/Salix + Claws-Mail/Gmail setup

, , ,

Pretty easy...these are the keypoints...

BASIC

-Server for receiving: pop.gmail.com
-SMTP server: smtp.gmail.com
-UserID: <username>@gmail.com
-Password: <yourpassord>

SEND

-ON : SMTP Authentication (automatic) / include UserID and password

SSL

-ON : Use SSL for POP3 connection
-ON : Use STARTTLS command to start SSL session

ADVANCE

-SMTP port: 587
-POP3 port: 995


Stop brute force attacks with these iptables examples

, ,

from: http://www.go2linux.org/linux/2010/04/stop-brute-force-attacks-these-iptables-examples-732

This technique, uses iptables to block a particular IP, that has passed the threshold of a certain number of connections in a given period of time.

I will show here, some basic IPtables rules to protect a web server from brute force attacks, but this example can be adapted to other scenarios.

Basic rules, only open port 80 (http) and 22 (ssh)
This is written as a script that may be run each time your server start, or can configured to run iptables as daemon, as I will show you later.

iptables -F
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp ! --tcp-option 2 -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -p tcp --dport www -j ACCEPT
iptables -P INPUT DROP
This IPtables script example, will close all port but ssh and www ports, but our server is still open to brute force attacks, so let's close this by adding two more rules that will only permit a certain number of connections to our server from a given IP.

Stop brute force attacks
Here is the example that will stop the brute force attacks.

iptables -F
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp ! --tcp-option 2 -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -p tcp --dport www -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 \
--hitcount 2 -j DROP
iptables -P INPUT DROP
If we now run

sudo iptables -L

This is the output

Chain INPUT (policy DROP)
target prot opt source destination
DROP tcp -- anywhere anywhere tcp dpt:ssh state NEW recent: UPDATE seconds: 600 hit_count: 2 name: DEFAULT side: source
tcp -- anywhere anywhere tcp dpt:ssh state NEW recent: SET name: DEFAULT side: source
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
REJECT tcp -- anywhere anywhere tcp option=!2 reject-with tcp-reset
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:www

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
The last two lines do the trick. Here is a simple explanation of what they do:

This line:

iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
Starts a table with each IP that starts a connection to ssh port.

And this one:

iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 \
--hitcount 2 -j DROP
Counts the number of connections that IP makes to our server in time frame of 600 seconds, if the number of connectios passed 2 (hitcount). The server will not accept any more connections from that IP for 600 seconds.

You can adjust those values to better fit your needs.

Make it automatic
If you are running Debian or Ubuntu you may run:

sudo /etc/init.d/iptables save

If you are running Arch Linux run:

sudo /etc/rc.d/iptables save

And add iptable to the daemons part in the /etc/rc.conf file.

Logging the connections
If you want to keep a log of the failed connections write something like this:

iptables -F
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp ! --tcp-option 2 -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -p tcp --dport www -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 \
--hitcount 2 -j LOG
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 \
--hitcount 3 -j DROP
iptables -P INPUT DROP
Look that the LOG line has a hitcount number minor that the DROP line, this will make iptables to write a line like this:

Apr 26 20:44:44 arch kernel: IN=eth0 OUT= MAC=00:19:d1:ea:e6:3f:00:11:2f:8f:f8:f8:08:00 SRC=97.107.x.x DST=200.87.x.x LEN=60 TOS=0x00 PREC=0x00 TTL=52 ID=37839 DF PROTO=TCP SPT=50094 DPT=22 WINDOW=5840 RES=0x00 SYN URGP=0
In the /var/log/messages or /var/log/iptables.log depending on your Linux distribution

Edit: 04-28-2010

One of our readers send me an email with these contribution

These rules work well for ssh, but you did not address port 80.
For ssh, your rules are too restrictive for scp , you will lock yourself out too fast. I usually use 8-10 (rather then 2) for ssh.
For port 80 , if you wish to use iptables, use --limit
Apache (or other web servers) can handle many many connections per IP, so even this may be a little too restrictive :
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m limit --limit 30/minute --limit -burst 5 -j ACCEPT

The credit goes to: bodhi.zazen

Slackware repository with dependency support

,

Google Chrome :: Favorite extensions

,

Google Chrome browser is for me the best browser available right now. These are my favorite extensions:
-Blog this!
-Send from Gmail!
-Google Mail Checker Plus
-Cookie Monster
-IE Tab
-Proxy This Page
-Secbrowsing - plugin version checker

How to format USB memory stick to F32

Here is the answer. Type the following:

fdisk /dev/sda
Command (m for help): p

Disk /dev/sda: 128 MB, 128974848 bytes
4 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 248 * 512 = 126976 bytes

Device Boot Start End Blocks Id System

Command: n “Create new partition!”
p “Create primary partition!”
Partition number (1-4): 1
First cylinder: (enter for default)
Last cylinder: (enter for default)
Command: t
Hex code (type L to list codes): b
Command: a “Make partition #1 active!”
Partition number (1-4): 1
Command: p

Disk /dev/sda: 128 MB, 128974848 bytes
4 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 248 * 512 = 126976 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1015 125829 b FAT32

Command: w “Write table to disk and exit!”

Format the USB drive with a FAT filesystem.

mkdosfs -F 32 /dev/sda1 “It will work with FAT32″

Top 5 linux distros for geeks

http://www.extremetech.com/article2/0,2845,2342647,00.asp

1. Slackware—the classic. Main release is very stable. You can use Slackware-Current to keep up with changes.

2. Arch Linux—possibly the most optimized binary distribution available. Similar to Slackware in structure, but simpler than Slackware in what it comes with—not a whole lot. This is not simple as in newbie simple, it is simple in terms of containing only the basics; you add what you want and put together config files yourself.

You can learn on this system because the documentation is very good, but you must be willing to read and research before you start out or you will not get very far. This is a great distro, but it is only designed for people who want to have complete control and set things up their way. Pacman is the fastest binary package manager, period.

3. Debian—another classic with Debian, you can get a rock solid stable version, which is awesome for server environments, but gets old quickly for desktop users. Debian Testing is a more reasonable compromise, but can still be aged. Debian Sid is unstable, provides cutting-edge software, but is known to have broken packages from time to time.

The sidux distribution is a Debian offshoot that same Sid irregularities and gives Sid some mood stabilizing medicine so that he won't "blow up the toys" any more—translation: sidux WORKS and is an awesome distribution for running cutting-edge stuff that works. Arch and Debian are near the forefront here.

4. Gentoo—one of the classic source based distributions. The project has recently fallen on hard times, but people who want to build their own source code based system still frequently turn to Gentoo.

5. Sabayon—a Gentoo offshoot that makes initial entry into the source based distro space a bit easier initially. I've not worked with this one much and I've heard mixed reports. Advocates say that it is easy to install initially, is fast, and has the same advantages as Gentoo. Detractors complain about quality issues, some of the same complaints that I've heard with Gentoo.

Three ways to securely access remote internal networks and work from home

,

from: http://polishlinux.org/linux/debian/three-ways-to-securely-access-remote-internal-networks-and-work-from-home/

Remote access to a computer and internal network’s secured resources - all of it in a simple way that’s following well-known security’s best practices? Sounds impossible, but it’s not. How to achieve it explains Bartosz Feński aka fEnIo.

A computer network with a tight security should be separated from the outside world as much, as it’s possible. It’s often the case. Even if there is a over a dozen of devices(PCs), that play different parts assigned to them in terms of company’s infrastructure, usually there is one that separates them from others, a firewall and a router.

On the assumption that the company’s policy is not too strict we often have an free access to this kind of devices. It can be various internal services, databases, servers of whatever is necessary to run a current company. What if, after work, when we are home safe and sound, we still need to connect to one of those servers that are not accessible outside the internal network.

I’ll describe few ways to do it.

SSH ProxyCommand
The simplest and, as far as I reckon, the most often case is when just behind firewall there is a 2nd server accessible by SSH, but only for LAN users. It’s similar to the situation, where router does NAT, and server’s addresses behind him are from private address’ classes. Therefore, If we want to log in, we need to log in to the firewall first.

Sounds familiar ? How many times have you actually tried to do the following:

laptop$ ssh router
[password1]
router$ ssh server
[password2]
server$
I’ve done it millions of times, and if someone does something often enough there is a chance that it would be so infuriating that eventually someone will try to automate it. SSH share the same story.

Let’s make an configuration file on a laptop ~/.ssh/config:

Host server
ProxyCommand ssh router nc %h %p 2> /dev/null
For this configuration to work a program called netcat is necessary, but most of the distributions have it in high-priority packages so it’s often already installed, so… How does the server connection looks like ?

laptop$ ssh server
[password1]
[password2]
server$
Let’s generate a key so we won’t be bothered about all the passwords.

laptop$ ssh-keygen
laptop$ ssh-copy-id router
laptop$ ssh-copy-id server
Login process is much more easier now:

laptop$ ssh server
server$
The coolest thing about it all is the fact, that along with the possibility of logging in to a device that is not public-accessible, we also get the full set of SSH features. There is no problem in using scp, sshfs, forwarding Xs or to set a tunnel to other device through a server.

But what if…

laptop -> router1 -> router2 -> ... -> routerN -> server

There are no barriers to add several devices to ~/.ssh/config and automate the whole login process even if u need to log in to few middle devices before logging in to the right one. You just need to define the right proxy command.

SSH SOCKS
SSH problem is solved, but what if the service we try to get to is, for example, a WWW server? We can use text browsers from the device we logged in, but it’s not really elegant or convenient.

We can use,mentioned earlier, port forwarding, that along with automatic login to different devices is a pretty flexible solution, but we need to remember to add certain SSH commands to every service or setting it all up in ~/.ssh/config)….

… but SSH function SOCKS saves the day:

laptop$ ssh -D 8080 router
[password1]
router$
If we generated a key, then we don’t need to give a password. We need to set up localhost as a SOCKS server and port 8080 in our browser. All connections will be tunneled to the router and visible for the WWW server as if they were initiated from this device.

Not every applications let’s you use SOCKS server though, but there is a cure. It’s called tsocks. It’s a simple program, that with the help of LD_PRELOAD variable, makes applications use the alternative versions of the connect(), sendto(), socket() functions. Thanks to that the applications can use middle servers almost without any dedicated configuration, unconsciously if we may use this term in reference to binary beings.

The configuration file should look as follows:

server = 127.0.0.1
server_type = 5
server_port = 8080
Now the applications, we’d like to “deceive” should be run:

laptop$ tsocks application_without_socks_support
As I’ve just presented, with SSH and a simple program we can quite easily organize our work environment and bypass limitations caused by a firewall. We can’t solve all our problems though. Let’s take our old FTP for example. It needs 2 ports to communicate, so it can’t be deceived in the way shown above. Moreover, if there is 40 services run on 30 devices behind firewall SSH configuration will be exceptionally complex and hard to maintain.

Perfect would be a solution, in which our laptop with a certain address’ class simply connects to through a channel to the targeted devices in a way, that the device knows the connection came from a secured and trusted network.

OpenVPN
OpenVPN solves the problem. To the contrary to SSH-based solutions, that works on 7th layer (application), OpenVPN works on 3rd (network)or even 2nd (transport) layer so it’s entirely transparent for the software. Moreover, it comes with authentication and encryption, so we don’t loose anything comparing to SSH.

Although since version 4.3 OpenSSH makes 2/3 layer tunneling possible,
but its configuration stands next to impossible.

OpenVPN allows making advanced configurations and, for instance, setting up a secured connection between several corporate branches. I’ll limit the example and only show how to gain access in the case described at the beginning of this article. Laptop will be a client and a VPN server will be configured on a router.

I assume, that openvpn package is installed on the laptop and the router. Let’s generate a key (that will be used to encrypt and authenticate the transmission) on the router.

router$ openvpn --genkey --secret /etc/openvpn/static.key

And a configuration file /etc/openvpn/server.conf:

dev tun
ifconfig 10.8.0.1 10.8.0.2
secret static.key
10.8.x class’ addresses will be used to set up a tunnel. You are free to choose your own addresses.

One thing left is to run the server:

router$ sudo /etc/init.d/openvpn start

We should get one more interface

tun0 Link encap:UNSPEC
HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Moreover we need to unlock the 1194 port in firewall setup.

We copy generated static.key on the laptop and we create client configuration file /etc/openvpn/client.conf:

remote routers_address
dev tun
ifconfig 10.8.0.2 10.8.0.1
secret static.key
route 192.168.0.0 255.255.255.0
Now we switch routers_address to its actual address. Route option will make a new record in routing table visible and from now all transfer is directed to the set up tunnel.

Last but not least thing we have to do is to run VPN on the laptop:

laptop$ sudo /etc/init.d/openvpn start
Let’s look at the routing table:

10.8.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
192.168.0.0 10.8.0.1 255.255.255.0 UG 0 0 0 tun0
That’s the way to set up the simplest configuration. Of course, as everything, It has its flaws. For example, everyone who has the key can access our network – sometimes though the key may fall into the wrong hands. OpenVPN has its own, more sophisticated authentication methods – simply get the generated key password-protected, but its security is far beyond this article framework.

Arch :: SVN tunneling through HTTP proxy

,

from: planet arch

SVN tunneling through HTTP proxy

I don’t know in your university, but in mine I still cannot use version control system cause we have an HTTP proxy and only HTTP traffic is allowed.
I want my system to be ever up-to-date and sometime this means to use development software. Today, for example, I wanted to build KDE from SVN.
Usually set http-proxy-host and http-proxy-port into ~/.subversion/server was enough, but today with this method I got a nice “Permission denied“.
The alternative method is to setup an SVN tunneling through the proxy:
First, you need perl-libwww from [extra] repository and perl-net-proxy from AUR.

Open a terminal and launch:

$ connect-tunnel -P proxyhost:proxyport -T 10234:svnhost:svnport
Now, keep connect-tunnel running and checkout svn in this way:

$ svn co svn://localhost:10234/svntrunk

All should works. Good luck!
February 2012
S M T W T F S
January 2012March 2012
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29