Wednesday, November 12, 2008

ssh tunel from linux

ssh -L 8080:192.168.2.254:80 user@address.org -p 22



Open your browser and go to http://localhost:8080 to see if your tunnel is working.

ssh -L localport:host:hostport user@ssh_server -N

where:
-L - port forwarding parameters (see below)
localport - local port (chose a port that is not in use by other service)
host - server that has the port (hostport) that you want to forward
hostport - remote port
-N - do not execute a remote command, (you will not have the shell, see below)
user - user that have ssh access to the ssh server (computer)
ssh_server - the ssh server that will be used for forwarding/tunneling

Without the -N option you will have not only the forwardig port but also the remote
shell. Try with and without it to see the difference.

Note:
1. Privileged ports (localport lower then 1024) can only be forwarded by root.
2. In the ssh line you can use multiple -L like in the example...
3. Of course, you must have ssh user access on secure_computer and moreover
the secure computer must have access to host:hostport
4. Some ssh servers do not allow port forwarding (tunneling). See the sshd man
pages for more about port forwarding (the AllowTcpForwarding keyword is set to
NO in sshd_config file, by default is set to YES)...

Example:


ssh -L 8888:www.linuxhorizon.ro:80 user@computer -N
ssh -L 8888:www.linuxhorizon.ro:80 -L 110:mail.linuxhorizon.ro:110 \
25:mail.linuxhorizon.ro:25 user@computer -N


The second example (see above) show you how to setup your ssh tunnel for web, pop3
and smtp. It is useful to recive/send your e-mails when you don't have direct access
to the mail server.

For the ASCII art and lynx browser fans here is illustrated the first example:

+----------+<--port 22-->+----------+<--port 80-->o-----------+
|SSH Client|-------------|ssh_server|-------------| host |
+----------+ +----------+ o-----------+
localhost:8888 computer www.linuxhorizon.ro:80

...And finally:
Open your browser and go to http://localhost:8888 to see if your tunnel is working.

Wednesday, September 24, 2008

linux adduser bash batch script

#!/bin/bash

NEW_USERS="/path/to/file.txt" #space separated user password group
HOME_BASE="/home/"

cat ${NEW_USERS} | \
while read USER password GROUP
do
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -g ${GROUP} -p ${pass} -m -d ${HOME_BASE}${USER} ${USER}
done

Monday, September 22, 2008

sshfs mount

sudo mkdir /mount/remote
sudo modprobe fuse
sshfs asdf@192.168.0.251:/ /mount/remote/

Friday, September 5, 2008

ltsp - xserver configuration

first in /etc/ltsp/dhcp.conf add/change this line: option root-path "/var/lib/tftpboot/ltsp/i386";
dhcp example:

authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.200 192.168.0.250;
option domain-name "example.com";
option domain-name-servers 192.168.0.150;
option broadcast-address 192.168.0.255;
option routers 192.168.0.150;
# next-server 192.168.0.1;
# get-lease-hostnames true;
option subnet-mask 255.255.255.0;
# option root-path "/opt/ltsp/i386";
option root-path "/var/lib/tftpboot/ltsp/i386";
if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
filename "/ltsp/i386/pxelinux.0";
} else {
filename "/ltsp/i386/nbi.img";
}
}


Then edit your /var/lib/tftpboot/ltsp/i386/lts.conf file.
Example:

[00:12:FB:01:74:AF]
# LDM_AUTOLOGIN=true
# LDM_USERNAME=ucenik01
# LDM_PASSWORD=ucenik
SOUND=False
XSERVER = sis
X_MODE_0 = 1280x1024
X_MODE_1 = 1024x768
X_MODE_2 = 800x600


Sunday, July 20, 2008

mpg123

VirginRadio
mpg123 -C -k 64 http://85.159.184.42:80

Play single mp3
mpg321 MP3_FILE_NAME

Create a list of all MP3 Files in the current folder…
find . -name "*.mp3"|sed 's/\.\///;'|sort>List.lst

Use this list as the play list for mpg321
mpg123 --list List.lst

Saturday, May 10, 2008

How to turn on automatic logon in Windows XP

1. Click Start, and then click Run.
2. In the Open box, type control userpasswords2, and then click OK.

Note When users try to display help information in the User Accounts window in Windows XP Home Edition, the help information is not displayed. Additionally, users receive the following error message:
Cannot find the Drive:\Windows\System32\users.hlp Help file. Check to see that the file exists on your hard disk drive. If it does not exist, you must reinstall it.
3. Clear the "Users must enter a user name and password to use this computer" check box, and then click Apply.
4. In the Automatically Log On window, type the password in the Password box, and then retype the password in the Confirm Password box.
5. Click OK to close the Automatically Log On window, and then click OK to close the User Accounts window.

Sunday, May 4, 2008

This will shutdown your box 1 minute after the file download completes:

sudo -s; wget http://www.theaddress.com/fiesty.iso; shutdown -h +1

TOO CANCEL A SHUTDOWN:

sudo shutdown -c