Thursday, September 10, 2009

iscsicli Examples

The original Link is here.

Users\john>sc config msiscsi start= auto

The output was:

[SC] ChangeServiceConfig SUCCESS

Then I entered:

Users\john>net start msiscsi

The output was:

The Microsoft iSCSI Initiator Service service is starting.
The Microsoft iSCSI Initiator Service service was started successfully.

Then, you use the Iscsicli command-line interface to connect to an iSCSI Target and list the available targets. The command I entered was:

Users\john>iscsicli QAddTargetPortal 192.168.1.31

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000
The operation completed successfully.

Next I entered:

Users\john>iscsicli ListTargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Targets List:
quorum
data
The operation completed successfully.

You can then connect to a target using the following code as an example:

Users\john>iscsicli qlogintarget data

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000
Session Id is 0xfffffa800626e018-0x4000013700000006
Connection Id is 0xfffffa800626e018-0x5
The operation completed successfully.

The following code checked to make sure the operation was successful:

Users\john>iscsicli reporttargetmappings

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Total of 1 mappings returned
Session Id : fffffa800626e018-4000013700000006
Target Name : data
Initiator : Root\ISCSIPRT\0000_0
Initiator Scsi Device : \\.\Scsi4:
Initiator Bus : 0
Initiator Target Id : 0
Target Lun: 0x0 <--> OS Lun: 0x0

The operation completed successfully.

You log out by using the logouttarget switch with the session ID, as the following sample code shows:

Users\john>iscsicli logouttarget fffffa800626e018-4000013700000006

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

The operation completed successfully.

To confirm the operation was successful, I entered the following code:

Users\john>iscsicli reporttargetmappings

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

No Mappings
The operation completed successfully.

The mappings obtained through the qlogintarget command aren’t persistent and will be lost at reboot. If you want a persistent connection, use the perssitenlogintarget switch, as the following code shows:

Users\john>iscsicli persistentlogintarget 
data
T * * * * * * * * * * * * * * * 0

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

The operation completed successfully.

To confirm that the operation was successful, I entered:

Users\john>iscsicli listpersistenttargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Total of 1 peristent targets
Target Name : data
Address and Socket : 192.168.1.31 3260
Session Type : Data
Initiator Name : Root\ISCSIPRT\0000_0
Port Number :
++Security Flags : 0x0
++Version : 0
++Information Specified: 0x20
++Login Flags : 0x8
++Username :

The operation completed successfully.

Entering T * * * * * * * * * * * * * * * 0 specifies all the required switches. To remove a persistent target, apply the information obtained from the listpersistentargets command, using the following code as an example:

Users\john>iscsicli removepersistenttarget Root\ISCSIPRT\0000_0 
data
* 192.168.1.31 3260

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

The operation completed successfully.

To confirm the success of the operation, I entered:

Users\john>iscsicli listpersistenttargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000
Total of 0 peristent targets
The operation completed successfully.

You'll notice that I passed the initiator name first, then the target name, the port number (which is *), and last of all the iSCSI target server IP address and socket.

Wednesday, September 9, 2009

Use Ubuntu ISCSI in Windows

Install the packages:

apt-get install libssl-dev
apt-get install iscsitarget

Edit /etc/default/iscsitarget and set:

ISCSITARGET_ENABLE=true

Make a new Partition or new disk, for Example /dev/sda3.

Edit /etc/ietd.conf:

change this line:
Lun 0 Path=/dev/sda3,Type=fileio

Restart the iscsitarget service:

/etc/init.d/iscsitarget restart

Use iscsi:

Windows:

Run iscsi-initiator, add the Ubuntu machine IP in Discovery tab, under Target Portals.

Connect to iscsi by pressing Log On, in Target tab. Close the iscsi-initiator.

Add iscsi Partition in Windows Partitions same as a new partition.


Linux:


run this command:

iscsiadm -m discovery -t st -p IP-FOR-ISCSI-TARGET

The informations of nodes are saving in /etc/iscsi/nodes.

Then run this:

iscsiadm -m node --targetname "UNIQUE-NAME-OF-TARGET" --portal "IP-FOR-ISCSI-TARGET:3260" --login


You can Mount the new device. See fdsik -l

Friday, September 4, 2009

Shutdown Computer Remotely

You can shut down from one Windows another Windows remotely:
in command prompt type:

c:/> shutdown -m \\COMPUTERNAME /s (/r for restart)


From Linux:
net rpc shutdown -I HOSTNAME(OR IP) -U USERNAME%PASSWORD

Friday, July 31, 2009

Pass Password to SSH Command

Install sshpass (Debian Package).

run ssh command as follow:

sshpass -p [yourpassword] ssh [yourusername]@[host]

Thursday, July 23, 2009

Find Windows XP Administrator Password

First reboot your windows with a Linux-Live CD such as ubuntu.

Take two files SAM and SYSTEM under folder WINDOWS\SYSTEM32\CONFIG.

With Rainbow Tables (for example OPHCRACK) you can find very fast the Password.

This HOW-TO tells you how to install OPHCRACK in Ubuntu:

HOW-TO INSTALL OPHCRACK ON Ubuntu

Ubuntu - Install all dependecies for a package

Run this command:

apt-get build-dep PACKAGE_NAME

Wednesday, July 15, 2009

Search and Replace in bash

#!/bin/bash
origvar="This is the original string";
replvar=${origvar//original/changed};
replvar=${replvar//string/result.};
echo "replvar==\"${replvar}\".";
echo "this should now state \"This is the changed result.\".";

Import Domain from Plesk 7 to Plesk 9

run in Plesk 7 this command:

/usr/local/psa/bin/pleskbackup -v domains DOMAIN.NAME /tmp/FILENAME

copy FILENAME to plesk 9 (for example tmp directory).

Add same Customer and domain in plesk 9.

Convert the Backup:

/usr/local/psa/bin/pre9-backup-convert -v convert -d /var/lib/psa/dumps/ /tmp/FILENAME

this command makes a XML file under /var/lib/psa/dumps/domains/DOMAIN.NAME

import the domain:

/usr/local/psa/bin/pleskrestore --restore /var/lib/psa/dumps/domains/DOMAIN.NAME/converted_DOMAIN.NAME_info_xxxxxxxxxx.xml -level domains

Wednesday, July 8, 2009

How to switch from Qmail to Postfix and vice versa?

You may run the following command to switch MTA to Postfix:

Code:

/usr/local/psa/admin/sbin/autoinstaller --select-release-current --install-component postfix
and for switching to Qmail:

Code:

/usr/local/psa/admin/sbin/autoinstaller --select-release-current --install-component qmail

Friday, June 5, 2009

Change Crontab Editor

In .bashrc add this line:

export EDITOR=/usr/bin/vim

or each editor you would have!

Thursday, June 4, 2009

Exmerge error: "Store 'MSPST MS' was not opened."

I was running an Exchange Server in English and then tried to move the accounts using exmerge to one in German when I ran into this error. After much reading I came accross this website: http://technet.microsoft.com/en-us/library/bb124178.aspx which states:

"Store 'MSPST MS' was not opened Store 'MSEMS' was not opened

The Store 'MSPST MS' was not opened or Store 'MSEMS' was not opened errors might be seen in the ExMerge log file (ExMerge.log) after merging data from the recovery storage group has failed. These errors typically indicate a language localization mismatch problem. The errors can usually be resolved by entering the correct localized names for the MAPI services on which ExMerge depends.

  1. In the ExMerge.ini file that is bundled with the ExMerge tool, find the LoggingLevel line and set its value to 3 instead of 0. This enables verbose logging of ExMerge errors.

  2. Run ExMerge again to generate the error condition again. To reduce the output to the log file, select only a single mailbox to merge.

  3. In the ExMerge.log file, find the lines that begin with "Checking service" and that are followed by a "was not opened" error. For example:

    [15:02:19] Checking service 'Microsoft Exchange Message Store'
    [15:02:19] Checking service 'Personal Folders'
    [15:02:19] Store 'MSPST MS' was not opened.
    [15:02:19] Ending Routine: EDKRoutines::OpenStores)
  4. In the ExMerge.ini file, find LocalisedExchangeServerServiceName and remove the semicolon (;) that precedes the line. Then set the value to the service name displayed in the ExMerge.log file. For example:

    LocalisedExchangeServerServiceName = Microsoft Exchange Message Store
  5. In the ExMerge.ini file, find LocalisedPersonalFoldersServiceName and remove the semicolon (;) that precedes the line. Then set the value to the service name displayed in the ExMerge.log file. For example:

    LocalisedPersonalFoldersServiceName = Personal Folders


So, simply find the localised names and remove the ';' from the one you need to use. For example, in my case I needed spanish so I removed it from the Spanish one and here is what I ended up with:

; French
;LocalisedPersonalFoldersServiceName=Dossiers personnels
; Spanish
LocalisedPersonalFoldersServiceName=Carpetas personales
; German
;LocalisedPersonalFoldersServiceName=Persönliche Ordner
; Italian
;LocalisedPersonalFoldersServiceName=Cartelle personali

From the looks of it, you will run into issues if you are using ExMerge for a French, Spanish, German or Italian system. Hope this helps!

Wednesday, May 27, 2009

Reset VTIGER Admin password

If you can get access to the database, try changing the user_password field value in vtiger_users table to:

adpexzg3FUZAk which makes the password as admin

mysql> update vtiger_users set user_password='adpexzg3FUZAk' where user_name='admin' ;


You will also need to set the crypt_type field of vtiger_users to blank (empty value) if you are on 5.0.4 and above.update

mysql> vtiger_users set crypt_type='' where user_name='admin' ;


Now the password for "admin" is "admin"!

NOTE: Once you login make sure to update the password to a secure one through 'My Preferences' link.

Wednesday, May 20, 2009

Ubuntu Encrypted directory with EncFS

Install the ENCFS package:

apt-get install encfs fuse-utils

modprobe fuse


Make the directory where encrypted data will be stored:

mkdir /encrypted

Make a mount point:

mkdir /temp-encr

use encfs with this directories:

encfs /encrypted /temp-encr

enter your Password.

for avoid the others to access the encrypted data, just unmount the folder:

fusermount -u /encrypted /temp-encr

In encrypted folder only "Encrypted Data" could be seen.

If you want to encrypt a directory on your fileserver and have the decrypted mountpoint accessible by Linux or Windows clients via Samba, you need to modify your setup slightly to permit "other" access to the Fuse device.

First, modify the /etc/fuse.conf file so that the last line "user_allow_other" does NOT have a leading hash. Save and exit.

Next, add an option to your EncFS mount command:

encfs /encrypted /temp-encr -- -o allow_other