Monday, December 27, 2010

[kr-en05] Compile asterisk without internet

Someday I needed to configure a PBX in a server without Internet access; when I was compiling Dahdi, it showed me an error that I solved following next steps.

Comment in dahdi-linux-complete- (the name of directory may change depending of your Dahdi version) some lines in the following way:
# Comment when there isn´t Internet access
#ifeq ($(HOTPLUG_FIRMWARE),yes)
# $(MAKE) -C drivers/dahdi/firmware hotplug-install DESTDIR=$(DESTDIR)

# $(MAKE) -C drivers/dahdi/firmware hotplug-uninstall DESTDIR=$(DESTDIR)

# $(MAKE) -C drivers/dahdi/firmware firmware-loaders

In the same file, edit the lines containning install-firmware and uninstall-firmware in the following way:
#install: all install-modules install-devices install-include install-firmware install-xpp-firm
install: all install-modules install-devices install-include install-xpp-firm

#uninstall: uninstall-modules uninstall-devices uninstall-include uninstall-firmware
uninstall: uninstall-modules uninstall-devices uninstall-include

Sunday, December 26, 2010

[kr-en04] Executing VM VirtualBox in background

In order to start a virtual machine in VirtualBox from GUI is necessary to have the virtual machines manager open. When you need to start a virtual machine remotely and only has access from a console, we present an useful procedure to carry on.

Start virtual machine "CGUNO-CentOS-5.2". This has to be the same name assigned during VM creation.
$ VBoxHeadless --startvm "CGUNO-CentOS-5.2" --vrdp=off&

Check process in execution
$ ps aux | grep Box
soporte 6222 75.2 3.1 320292 129004 pts/1 Sl 15:47 7:20 /usr/lib/virtualbox/VBoxHeadless --startvm CGUNO-CentOS-5.2 --vrdp=off
soporte 6236 0.0 0.1 82836 4256 pts/1 S 15:47 0:00 /usr/lib/virtualbox/VBoxXPCOMIPCD
soporte 6243 0.0 0.1 159752 6844 ? Sl 15:47 0:00 /usr/lib/virtualbox/VBoxSVC --pipe 8 --auto-shutdown
soporte 6297 0.0 0.0 7240 820 pts/1 R+ 15:57 0:00 grep Box

Check if you have ping answer from machine previously started
$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=2.72 ms
64 bytes from icmp_seq=2 ttl=64 time=0.102 ms
--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1005ms
rtt min/avg/max/mdev = 0.102/1.415/2.729/1.314 ms

Add a command line in rc.local file in order to start the VM during operating system booting
[root@localhost]# vim /etc/rc.local
#!/bin/sh -e

VBoxHeadless --startvm "CGUNO-CentOS-5.2" --vrdp=off&

[kr-en03] Using wget and apt through proxy

A lot of times is necessary to download some file or source code from command line, in a remote sever wich have access to Internet through proxy server, using commands such as wget and apt, in a distro like Debian.

Setting the HTTP_PROXY variable value were usefull in order to download a file using wget, but it wasn´t the same for apt.
# export HTTP_PROXY=""

In some case, previous instruction didn´t work, for that reason we recommend to use next command line
# wget

Adding a file named proxy in the apt.conf.d dir, work out for apt package manager
# vim /etc/apt/apt.conf.d/proxy
Acquire::http::Proxy "";

Saturday, December 25, 2010

[kr-en02] SSH without password

Sometimes is necessary to make backups between devices through some kind of script or web app. Is in this cases when password authentication becomes an obstacle for automatization and where is needed to use public and private keys. This time, we'll use a Debian distro, but it wont be different in another one.
Server IP:
Server user:soporte
Client IP:
Client user:krtapas
Configure next parameters in server's sshd_config file
[root@server]# vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes

Access client equipment and create keys without password
[krtapas@client]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/krtapas/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/krtapas/.ssh/id_rsa.
Your public key has been saved in /home/krtapas/.ssh/
The key fingerprint is:
19:02:a6:64:2f:4d:c9:1e:73:54:d5:50:e7:73:73:ab krtapas@client

Create .ssh directory in the server and in the user folder with we'll give access without password
[soporte@server]$ cd /home/soporte/
[soporte@server]$ mkdir .ssh

Create in server, file authorized_keys with the content of file obtained from the client equipment. We're copying the public key, the private one must not be known for anyone in the exterior.
[krtapas@client]$ scp /home/krtapas/.ssh/ soporte@
soporte@'s password:

Finally, it will be possible to authenticate from client equipment, without asking password from server.
[krtapas@client]$ ssh soporte@
Last login: Fri Jan 15 16:14:03 2010 from

[kr-en01] Recover MySQL root password

In case you've forgotten your MySQL root password, we'll show you some easy steps to set a new one. The process will be carry on with CentOS commands but it will be similar on another distro.

Stop MySQL service
# service stop mysqld

Start service with special parameters in wich you wont need any password
# mysqld_safe --skip-grant-tables --skip-networking --user=mysql &
[1] 29800
# Starting mysqld daemon with databases from /var/lib/mysql

Verify that the process had been started with previous options
# ps aux | grep mysql
root 29800 0.0 0.0 4484 1112 pts/0 S 18:30 0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables --skip-networking --user=mysql
mysql 29852 0.0 0.4 136268 17420 pts/0 Sl 18:30 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/ --skip-external-locking --socket=/var/lib/mysql/mysql.sock --skip-grant-tables --skip-networking
root 29889 0.0 0.0 3940 732 pts/0 S+ 18:30 0:00 grep mysql

Acces MySQL without password
# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


Change root password and quit
mysql> update user set password=password('0p3nMySQLGr0up') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

Check access with new password
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.