Recover root password.

1. Boot the LiveCD or rescue CD/USB, and mount your root (/) partition. For example:

mkdir /mnt/root
mount /dev/sdaX /mnt/root

and then edit the password file with your editor:

vim /mnt/root/etc/shadow

and then delete the second field on the root line:

root:$1$KmZw.u7l$JI6aYJRrSU7ZcUivaNQpZ1:15833:0:99999:7:::

2. Boot the LiveCD or rescue CD/USB, and mount your root (/) partition. For example:

mount -o remount,rw /dev/sdaX /mnt/root
chroot /mnt/root
passwd root

3. INIT or /bin/bash mode

Another trick is to add “init=/bin/bash” (LILO “linux init=/bin/bash” or add it to the Grub “kernel” line). This will dump you to a bash prompt much earlier than single user mode, and a lot less has been initialised, mounted, etc. You’ll definitely need the “-o remount,rw” here. Also note that other filesystems aren’t mounted at all, so you may need to mount them manually if you need them. Look in /etc/fstab for the device names.

passwd root

🙂

How to install and set up VPN (PPTP) server on Debian Linux.

PoPToP Point to Point Tunneling Server, this implements a Virtual Private Networking Server (VPN) that is compatible with Microsoft VPN clients. It allows windows users to connect to an internal firewalled network using their dialup.

Install pptpd:

root:# apt-get install pptpd

and then edit the configuration file:

root:# vim /etc/pptpd.conf

and add the following lines to:

localip 192.168.1.144
remoteip 192.168.1.200-225, 192.168.1.230

# Specifies the local and remote IP address ranges.
#
# Any addresses work as long as the local machine takes care of the
# routing. But if you want to use MS-Windows networking, you should
# use IP addresses out of the LAN address space and use the proxyarp
# option in the pppd options file, or run bcrelay.

then edit the configuration file:

root:# vim /etc/ppp/pptpd-options

and add the following lines to:

ms-dns 192.168.1.44 # my DNS server
nobsdcom
noipx
mtu 1490
mru 1490

edit another one configuration file:

root:# vim /etc/ppp/chap-secrets

and add the following lines to:

username * password *

then restart the pptpd service:

root@server: service pptpd restart

and don’t forget to enable 1723 on a firewall.

TightVNC Remote Desktop Connections using SUSE as Client or Server.

1. Install the tightvnc and xorg-x11-Xvnc packages:

root# zypper install tightvnc xorg-x11-Xvnc

Type the command vncserver to start the VNC server, and then type the command
vi $HOME/.vnc/xstartup
to open the VNC configuration file in the vi text editor. You can replace “vi” with your preferred text editor.
Add the line /usr/bin/gnome & under the #!/bin/sh line, if you are using the Gnome desktop.

Type the command vncserver in Suse 10 or dbus-launch vncserver in Suse 11, to start the VNC server. Take note of the desktop number, usually “:1,” “:2” or “:3,” that is shown after the command is executed.

2. Connect to the Server

Open the VNC viewer software on the remote computer. Type “192.168.1.100:1” in the connection text box. Replace “192.168.1.100” with the IP address of the Suse server. Replace “:1” with the desktop number from the previous section. and then type the password for the VNC server, when prompted.

Users who are logged on can start a server with a simple console command.

• Starting the server in Suse versions 10.x: vncserver
• Starting the server in Suse versions 11.x: dbus-launch vncserver

The vncserver command will start the next unused desktop in the sequence :1, :2, :3 …etc. You can attach many options to the command line when starting the server. There are options specific to TightVNC on the TightVNC man page and you can also attach the options listed in the Xvnc man page.

Note: vncpasswd allows you to set the password used to access VNC desktops. Its default behavior is to prompt for a VNC password and then store an obfuscated version of this password to passwd-file (or to $HOME/.vnc/passwd if no password file is specified.) The vncserver script runs vncpasswd the first time you start a VNC desktop, and it invokes Xvnc with the appropriate -rfbauth option. vncviewer can also be given a password file to use via the -passwd option. The password must be at least six characters long (unless the -f command-line option is used– see below), and only the first eight characters are significant. Note that the stored password is not encrypted securely – anyone who has access to this file can trivially find out the plain-text password, so vncpasswd always sets appropriate permissions (read and write only by the owner.) However, when accessing a VNC desktop, a challenge-response mechanism is used over the wire making it hard for anyone to crack the password simply by snooping on the network.

conf example:


server:/home/user/.vnc # cat xstartup
#!/bin/sh

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

Send an email via telnet.

To send an email via telnet just type:

root:~# telnet 172.16.12.25 25
220 hostname.com Internet Agent 0.0.3
HELO domain.com
250 hostname.com Ok
MAIL FROM: you@hostname.com
250 Ok
RCPT TO: them@hostname_away.com
250 Ok
DATA
354 Enter mail, end with "." on a line by itself
ie, type your message or whatever
.

250 Ok
quit
221 hostname.com Closing transmission channel
Connection to host lost.

By the way, you will not see any AUTH listed when connecting and doing an ehlo. In addition any attempt to auth will be met with the error:

035.5.1 Error: authentication not enabled

It will not display options for smtp authentication unless a TLS security is used to connect.

Try connecting with:

openssl s_client -connect localhost:25 -starttls smtp

Now you will see the 250-AUTH PLAIN LOGIN on ehlo and you will be able to auth.

When posting logs of the SASL negotiations to public lists, please keep in mind that username/password information is trivial to recover from the base64-encoded form.

You can use one of the following commands to generate base64 encoded authentication information:

Using a recent version of the bash shell:

echo -ne '00username00password' | openssl base64

Some other shells support similar syntax.

Using the printf command:

printf '%s%s' 'username' 'password' | openssl base64
printf '%s%s' 'username' 'password' | mmencode

The mmencode command is part of the metamail software.

root:~# openssl s_client -connect 4network.eu:25 -starttls smtp

and the output:

Compression: 1 (zlib compression)
Start Time: 1373377800
Timeout : 300 (sec)
Verify return code: 18 (self signed certificate)
---
250 DSN

and then type:

ehlo domain.org
250-hades
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

auth plain AGpvbGFudGEAam9sYW50YQ==
235 2.7.0 Authentication successful

SMTP Status Codes
You may notice along the way that after typing commands you see responses from the server starting with “250″. 250 is a good thing, and there are a lot of other SMTP status codes you’ll encounter the more you use this technique.
Continue reading “Send an email via telnet.”

How to browse the eDir using ldapsearch.

To browse the eDir use the Linux ldapsearch command:


ldapsearch -x -h 172.16.12.182 "(objectclass=Person)" > all.text

Used filter “objectclass=Person” will out put all records of users to the all.text file


ldapsearch -x -h 172.16.12.182 "(objectclass=Person)" uid fullname mail loginTime passwordEcpirationTime loginTime > selected.text

Used filter “objectclass=Person” and requested records “uid fullname mail loginTime passwordEcpirationTime loginTime” will out put just selected records of users to the selected.text file.

Create the /dev/random

In SUSE Linux Enterprise Server 10 the /dev/random is missing, to create it use the mknod command (mknod – make block or character special files):

mknod /dev/random c 1 9

The /dev/random is a special file that serves as a random number generator or as a pseudorandom number generator. It allows access to environmental noise collected from device drivers and other sources.[citation needed] Not all operating systems implement the same semantics for /dev/random. Linux was the first operating system to implement a true random number generator in this way.

Display a directory as a web page.

Let’s say you want to allow someone access to files quickly via a web browser on your machine. You can do that with the help of python. All you do is change into the directory you want to serve up and then run the command:

python -m SimpleHTTPServer

Now, whoever needs to view that page simply points their browser to http://ADDRESS_OF_MACHINE:8000

Where ADDRESS_OF_MACHINE is either the IP Address or Domain of the machine (whichever applies). The user will then be able to navigate the files and folders within the directory you are serving up.

Disabling the SUSE boot splash screen with the little white progress bar.

To disable the green SUSE boot splash screen with the little white progress bar:

vi /boot/grub/menu.lst
and set “splash=silent” to “splash=verbose” That will do 🙂
or/and enter the command echo 0 >/proc/splash on the command line to disable the graphical screen. To activate it again, enter echo 1 >/proc/splash.

iSCSI – Initiator and Target.

The target is the name of the iSCSI server. The iSCSI server offers its devices (disks, tape, dvd/cd, etc.) to the clients. One device can by accessed by a few clients.

At first we have to set up a target server:

debian# apt-get install iscsitarget iscsitarget-dkms

then edit the configuration file:

debian# vi /etc/default/iscsitarget

and then, set ISCSITARGET_ENABLE to true: “ISCSITARGET_ENABLE=true“.

Now, we can create a volume group:

debian# vgcreate vg1 /dev/sdc1

but before that, you have to use fdiks to create Linux LVM partition. The next step is to initializes PhysicalVolume for later use by the Logical Volume Manager (LVM):

debian# pvcreate /dev/sdc1

and then, create a logical volume in an existing volume group:

debian# lvcreate -L2000M -n disk_sdc vg1

Now, we can add the “sdc1” disk to /etc/iet/ietd.conf and comment out everything in that file.


Target iqn.2012-10.com.home:disk.sdc
Lun 0 Path=/dev/vg1/disk_sdc,Type=fileio
Alias LUN1
MaxConnections 0

and then, and start the target:

debian# /etc/init.d/./iscsitarget start

The initiator is the name of the iSCSI client. The iSCSI client has a block level access to the iSCSI devices, which can be a disk, tape drive, DVD/CD writer. One client can use multiple iSCSI devices.

To install the initiator:

debian# apt-get install open-iscsi

and then, edit the /etc/iscsi/iscsid.conf file, and set node.srartup to automatic

node.startup = automatic

and then, restart the initiator:

debian# /etc/init.d/./open-iscsi restart

Discover targets using the discovery record with the recid matching the the discovery type and portal passed in. If there is no matching record, it will be created using the iscsid.conf discovery settings. This must be passed in discoverydb mode to instruct iscsiadm to perform discovery. This option is only valid for SendTargets discovery mode.

To do this:

debian# iscsiadm -m discovery -t st -p 192.168.1.100

output:

debian# iscsiadm -m discovery -t st -p 192.168.1.100
192.168.0.100:3260,1 iqn.2012-10.com.home:disk.sdc

Specify the mode. op must be one of discoverydb, node, fw, host iface or session.
If no other options are specified: for discoverydb and node, all of their respective records are displayed; for session, all active sessions and connections are displayed; for fw, all boot firmware values are displayed; for host, all iSCSI hosts are displayed; and for iface, all ifaces setup in /var/lib/iscsi/ifaces are displayed.

and then:

debian# iscsiadm -m node

and finally we can log in, either by running:

iscsiadm -m node --targetname "iqn.2012-10.com.home:disk.sdc" --portal "192.168.1.100:3260" --login

Ohh… that’s useful:

debian# cat /proc/net/iet/volume
debian# cat /proc/net/iet/vsession