ssh reverse tunning..

If you want to access some local resources like the release website from the remote server when you are connecting to the remoter server using ssh over VPN, then possibly reverse ssh tunnelling is the best option. So, basically when you are connecting to the remote server, you tell the server your intent to do so and which local resource you want to connect to and on which port.So, here I want to connnet to google.com and tunnel the data to 192.168.131.921:9090 tthough the tunnel, then the command to use will be  ::

ssh google.com -R 8010:172.16.131.92:9090

Now, on the remote server whenever you want to connect to 172.16.131.92:9090, you can do wget http://localhost:8010….

Enhanced by Zemanta

phpmyadmin access problem and change server from URL

I was having issues with one of the phpmyadmin setups. The first server defined in the config file was not accessible and the theme that I was using was not allowing me to change the server from the first page. This resulted in a state where I was not able to access phpmyadmin in any way. I could not connect to any of the servers. And thus had to hack my way in to phpmyadmin to find out how to connect to other servers from URL. And here is my finding:

http://server/phpmyadmin/index.php?server=1

In the above, replace server with your server address/IP. and also the number in the end with the server index in you phpmyadmin config file.

Enhanced by Zemanta

mysql output to an array for easy parsing.

 

Today I was looking for some way to put the output of the mysql output in an array in a bash script. Quick google search yeilded to results something like this:

 

1
output=$(mysql -e "select * from table")

The problem with the above approach is that all the words go into separate index. So if you have a line that has space then that is split into multiple index’s. Not good…

So, I finally came up with something that would not do so and would seperately put each column in each item in the array.

1
2
3
4
5
6
7
8
9
10
IFS="|"
host="hostname"
user="username"

pw="password"
ar=( $(echo 'select id,"| Account ::",account,"| Username ::",username,"| Password ::",password,"| Other Deatils ::",otherdetails,"|END|"  from wp_ak_login' |mysql -D $user -h $host -p$pw -u $user --batch --raw ) )
for i in ${ar[@]}
do
echo $i --
done

 

And if you are a big fan of xml and plan to use xmlstarlet to process the output then you can do the following:

1
2
3
4
5
6
7
8
9
10
IFS="|"
host="hostname"
user="username"

pw="password"
ar=( $(echo 'select id,"| Account ::",account,"| Username  ::",username,"| Password ::",password,"| Other Deatils  ::",otherdetails,"|END|"  from wp_ak_login' |mysql -D $user -h $host  -p$pw -u $user --batch --raw --xml) )
for i in ${ar[@]}
do
echo $i --
done

Hope this will help

Enhanced by Zemanta