Posts

eavesdropping in ssh

This happens when we are switching from old server to another server and assigned a different IP address from the specific domain name. bash-3.1$ ssh myname@example.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: POSSIBLE DNS SPOOFING DETECTED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ The RSA host key for example.com has changed, and the key for the according IP address 198.2.1.1 is unchanged. This could either mean that DNS SPOOFING is happening or the IP address for the host and its host key have changed at the same time. Offending key for IP in /home/myname/.ssh/known_hosts:16 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host ke...

find and perl as alternative for sed

In continuation of my migration, some directories with HTML contents their are manually inputted by strings that would let a typical user to edit manually all the HTML files for just a sake of changing a text. However, Perl as an alternative for sed is quite helpful. The command goes like this: perl -e "s/www\.hawaiifsbos\.com/test\.hawaiifsbos\.com/g;" -pi $(find . -type f) -p = will do a loop sequence. For more info, read the page in " Using the -n and -p option " -i = will modify file in-place. providing after the "i" letter with a word, will be used as a back-up suffix of a file. (Ex. -pi.bak) -e = means execute This is the same thing as find . -name "*.*" -type f -exec sed -i 's/www.mysite.com/test.mysite.com/g' {} \; The above works in my Slack, but it seems weird it doesn't do in FreeBSD, but the perl is there as my alternative.

rsync: avoid overwriting of files

I was migrating this stuffs we have from an old FreeBSD 4.0 Server to a new FreeBSD 6.0 Server hosted at Verio. I was fumbled and tumbled when I use this rsync tool by migrating the files to our new server. The situation is that, in every directories we have being assigned in a virtual host and its DocumentRoot are having different owners and group assigned. The old server we have is having a version of an old Apache . Now, in order to achieve the exact ruling or permission, rsync is a tool that enables you to preserve ownership as well as its permission of the files/directories that you're going to copy--or shall we use the term "migrate". My mistake was that, migrating with files using rsync is a little bit tricky. Ending a copy like this, for example: rsync -r -e "ssh -l ahkmed" localhost:/home/ahkmed/documents /www/documents is a different story than rsync -r -e "ssh -l ahkmed" localhost:/home/ahkmed/documents/ /www/documents Note the ending has s...

Installing MySQL v6 in FreeBSD

FreeBSD places its packages under /usr/ports/. Now for databases, types this command cd /usr/ports/databases/mysql60-server Then issue make after make, issue make install You can even specify it's configuration options like --prefix by doing "make install --prefix=/usr/local" where it will install the mysql packages. This is applied also to the client package, just follow the steps how the server is being installed. Create /var/db/mysql if that direcotry doesn't exist, then " chown mysql:mysql /var/db/mysql " and " chmod 770 /var/db/mysql " for security. Run the mysql_install_db command which will create default tables that mysql will used on its server process. Run the mysql background process by issuing the command " /usr/local/etc/rc.d/mysql-server start " or perhaps it might be " /usr/local/etc/rc.d/mysql-server.sh start ". I think older BSD preserves the .sh suffix on the start up scripts. Don't forget to provide pass...

rsync using ssh via a sudo command

My main goal for this is, I was migrating from an old server to a new BSD server. In order to make preservation of user accounts, I manage it with this command below using rsync tool to transfer or copy the files. "rsync -p -o -g -r -a -v -e "ssh -l normaluseraddedviasudoers" --rsync-path "sudo rsync" --delete oldserver.com:/home . --log-file=/tmp/rsynclogs.txt " -p means to preserve the permission, -o means to preserve the ownership, -g means to preserve the group. -r means to recurse into ts sub-directories, -a means to archive them, -v means to use the verbose mode, -e specifies the remote login to use. With --rsync-path, it makes how to run rsync which this means like run the rsync via sudo or via root. Now, I am able to copy all the files under /home directories without prior chmod afterwards when you are on the new server. It makes the rsync set everything for you and not worrying if the files has been able to copy or not it's because you might...

Javascript catching mouse click event and know what DOM element is being clicked

Asking some great encoders in irc.freenode at #javascript channel, people are having an extensive help to me. I got this code working, but here I use the mootools JS Library but still the same as native javascript syntax. $(document).addEvent('click', function(e){ console.info(e.target.get('id')); }); // This works in IE $(document).attachEvent('onclick', function(e){ alert(e.srcElement.id) // gives the id of the element being clicked }); Through it, it does prints or gives me the id of the element being clicked. It's really cool knowing this technique.

Counting the tables in MySQL Database

Finding ou how cool MySQL is, I gathered this statement that might be useful when doing a CLI tasks. select count(*) as number_of_tables from information_schema.tables WHERE table_schema='schema_name'; OR select count(*) as number_of_tables from information_schema.tables WHERE table_schema='schema_name' and table_type = 'BASE TABLE' ; The latter one does only selects those base tables, BASE TABLE is actually a MySQL valid value of a table_type. This link can give some information about schema -> http://dev.mysql.com/doc/refman/5.0/en/information-schema.html