Wednesday 11 February 2009

Two ways to copy files from a remote computer securely

Run any of the two following commands from the destination computer, previously located in the destination directory.

rsync -avz -e ssh root@192.x.x.x:/s01/backup/oradata/databkup/* .

scp root@192.x.x.x:/s01/backup/oradata/databkup/* .

After cloning a Linux box problems running vnc server, xterm can not run

After cloning a Linux box, running vnc server, a terminal connection could not start xterm. (I clonned a virtual server into a virtual server, on vmware ESX 3.5)
The log file (located at /home/username/.vnc/hostname:1.log) was as follows:

Wed Feb 11 11:27:53 2009
Client: Server default pixel format depth 16 (16bpp) little-endian rgb565
Client: Client pixel format depth 6 (8bpp) rgb222
xterm: Error 32, errno 2: No such file or directory
Reason: get_pty: not enough ptys


I think the two steps that solved it were:

1) create a new .Xauthority file
Loged in as username:
Delete the .Xauthority file, located at /home/username
Create a new .Xauthority file, issuing the command: $mkxauth -c

2) use makedev to create the pty and pts devices:
Loged in as root:

cd /dev
./MAKEDEV pty
./MAKEDEV ptm


Steps found at:

a) http://www.gelato.unsw.edu.au/IA64wiki/XinChroot

host:/# xterm
xterm: Error 32, errno 2: No such file or directory
Reason: get_pty: not enough ptys
try running MAKEDEV pty in /dev to make the devices you need.



b) http://mail-index.netbsd.org/pkgsrc-users/2008/07/09/msg007591.html


cannot start xterm on NetBSD-4.0

--------------------------------------------------------------------------------

To: pkgsrc-users%netbsd.org@localhost
Subject: Re: cannot start xterm on NetBSD-4.0
From: Aleksey Cheusov
Date: Thu, 10 Jul 2008 00:46:55 +0300

--------------------------------------------------------------------------------

>> - After manual running the following commands
>> cd /dev
>> ./MAKEDEV ptm
>> mkdir pts
>> mount pts

> You can add this to MAKEDEV under "init)":
> makedev ptm
> mkdir -m 0755 /dev/pts

I've added this code to /etc/rc.local (because /dev is on MFS)
and everything works fine now while booting.
But this is strange ;-( Before HDD failure everything worked fine
without this code.

>> xterm seems to work but says
>> utmp_update: Cannot update utmp entry: Resource temporarily unavailable
>> utmp_update: Cannot update utmp entry: Undefined error: 0

> Have you searched for "Cannot update utmp entry"? Same problem, same solution?
Thank you. I've found it :-) I really forgot -U option of build.sh

--
Best regards, Aleksey Cheusov.



I also made as root:

set DISPLAY=:0.0
export DISPLAY

Monday 9 February 2009

Change name of server, after install SQL Server 2005

If you change the name of a server / computer, after installing SQL server 2005 (it happened to me also for SQL 7.0 server and SQL 2000 server), some of the programs that have access to the database, will have problems, because of the default instance was using the old name.
A long time ago, I had to backup my databases, uninstall SQL server, change the server name, reinstall SQL server, and restore the databases ....
But the solution is very simplistic: change the name of the server, and after restarting it, launch the SQL Management Studio (Enterprise Manager or Query Analyzer if using SQL server 2000), then execute the following queries:

1) select @@servername
It will show you the actual server name used by SQL server

2) sp_dropserver OLDNAME
GO
It will erase this parameter

3) sp_addserver NEWNAME, local
GO
It will configure the SQL server parameter with the new name

4) Restart SQL server services

5) select @@servername
It will show you the actual NEW server name used by SQL server. Try at least twice.

You're all done.
It works for the default instance.
If you need to read further, go to http://msdn.microsoft.com/en-us/library/ms143799.aspx

Thursday 5 February 2009

VMware virtual machines grayed out in Virtual Center

It happened to me already twice, with no apparent cause. Fortunately, the resolution is very straightforward, you just need to restart the management agents on ESX server.

Here is the link to VMware site:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003490

Here is the contents of it, so you can follow the procedure easily:

Restarting the Management agents on ESX Server 3.x

To restart the management agents on ESX Server 3.x:
  1. Login to your ESX Server as root from either an SSH session or directly from the console of the server.
  2. Type service mgmt-vmware restart .

    Caution: Ensure Automatic Startup/Shutdown of virtual machines is disabled before running this command or you risk rebooting the virtual machines. For more information, see Restarting hostd (mgmt-vmware) on ESX Server Hosts Restarts Hosted Virtual Machines Where Virtual Machine Startup/Shutdown is Enabled (1003312).
  3. Press Enter.
  4. Type service vmware-vpxa restart .
  5. Press Enter.
  6. Type logout and press Enter to disconnect from the ESX Server.
If this process is successful, it appears as:
[root@server]# service mgmt-vmware restart
Stopping VMware ESX Server Management services:
VMware ESX Server Host Agent Watchdog [ OK ]
VMware ESX Server Host Agent [ OK ]
Starting VMware ESX Server Management services:
VMware ESX Server Host Agent (background) [ OK ]
Availability report startup (background) [ OK ]
[root@server]# service vmware-vpxa restart
Stopping vmware-vpxa: [ OK ]
Starting vmware-vpxa: [ OK ]
[root@server]#

Restarting the Management agents on ESX Server 3i

To restart the management agents on ESX Server 3i:
  1. Connect to the console of your ESX Server.
  2. Press F2 to customize the system.
  3. Login as root .
  4. Using the Up/Down arrows navigate to Restart Management Agents.
  5. Press Enter.
  6. Press F11 to restart the services.
  7. When the service has been restarted, press Enter.
  8. Press Esc to logout of the system.

Command to delete user password under Linux

Type the following command to delete a user password:

# passwd --delete username

OR

# passwd -d username

Above command delete a user's password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless. User will not able to login.

It is also a good idea to setup user shell to nologin to avoid security related problems:

# usrmod -s /sbin/nologin username

For example to delete password for user johnc, Type:

# passwd -d johnc
# usrmod -s /sbin/nologin johnc