Monday, May 28, 2012

rsync over ssh

ref: http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/


1. Test rsync over ssh (with password):

Do a rsync to make sure it asks for the password for your account on the remote server, and successfully copies the files to the remote server.
The following example will synchronize the local folder /home/ramesh to the remote folder /backup/ramesh (on 192.168.200.10 server).
We discussed in detail about rsync in our previous 15 rsync examples articles.
This should ask you for the password of your account on the remote server.
rsync -avz -e ssh /home/ramesh/ ramesh@192.168.200.10:/backup/ramesh/

2. ssh-keygen generates keys.

Now setup ssh so that it doesn’t ask for password when you perform ssh. Use ssh-keygen on local server to generate public and private keys.
$ ssh-keygen
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Note: When it asks you to enter the passphrase just press enter key, and do not give any password here.

3. ssh-copy-id copies public key to remote host

Use ssh-copy-id, to copy the public key to the remote host.
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.200.10
Note: The above will ask the password for your account on the remote host, and copy the public key automatically to the appropriate location. If ssh-copy-id doesn’t work for you, use the method we discussed earlier to setup ssh password less login.

4. Perform rsync over ssh without password

Now, you should be able to ssh to remote host without entering the password.
ssh 192.168.200.10
Perform the rsync again, it should not ask you to enter any password this time.
rsync -avz -e ssh /home/ramesh/ ramesh@192.168.200.10:/backup/ramesh/

Wednesday, May 02, 2012

Dreamweaver: Remove double spaces between lines

Ref: http://forums.digitalpoint.com/showthread.php?t=622323


  1. Open the file
  2. Click CTRL + F
  3. Select "Current document" in "Find in" (You can also select the folder if you have multiple files)
  4. Search in "Source code"
  5. Tick "Use regular expression"
  6. Type "[\r\n]{2,}" (without quotes) in "Find"
  7. Type "\n" (without quotes) in "Replace"
  8. Press "Replace All"

Sunday, April 22, 2012

Nginx TLS SNI Enabled

source: http://www.falsyana.com/2011/linux/multiple-ssl-sites-on-1-ip-nginx/

Chrome OK:

Mozilla OK:

IE9 Not OK:


nginx -V
nginx version: nginx/1.0.12
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
TLS SNI support enabled

Thursday, April 19, 2012

linux copy with progress bar

http://www.falsyana.com/2010/linux/cp-mv-with-a-progress-bar/

#vi ~/.bash_rc

1
2
alias cp='rsync --progress -ah'
alias mv='rsync --progress -ah --remove-sent-files'

Tuesday, April 10, 2012

generate random mac address [python]


#echo 'import virtinst.util ; print virtinst.util.randomMAC()' | python
ref: http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html-single/Virtualization/index.html

other scripts:

Generating a new unique MAC address

In some case you will need to generate a new and unique MAC address for a guest. There is no command line tool available to generate a new MAC address at the time of writing. The script provided below can generate a new MAC address for your guests. Save the script to your guest as macgen.py. Now from that directory you can run the script using ./macgen.py and it will generate a new MAC address. A sample output would look like the following:
$ ./macgen.py 
00:16:3e:20:b0:11
 
#!/usr/bin/python
# macgen.py script to generate a MAC address for virtualized guests on Xen
#
import random
#
def randomMAC():
 mac = [ 0x00, 0x16, 0x3e,
  random.randint(0x00, 0x7f),
  random.randint(0x00, 0xff),
  random.randint(0x00, 0xff) ]
 return ':'.join(map(lambda x: "%02x" % x, mac))
#
print randomMAC()
Another method to generate a new MAC for your guest
You can also use the built-in modules of python-virtinst to generate a new MAC address and UUID for use in a guest configuration file:
# echo  'import virtinst.util ; print\
 virtinst.util.uuidToString(virtinst.util.randomUUID())' | python
# echo  'import virtinst.util ; print virtinst.util.randomMAC()' | python
The script above can also be implemented as a script file as seen below.
#!/usr/bin/env python
#  -*- mode: python; -*-
print ""
print "New UUID:"
import virtinst.util ; print virtinst.util.uuidToString(virtinst.util.randomUUID())
print "New MAC:"
import virtinst.util ; print virtinst.util.randomMAC()
print ""
Related Posts Plugin for WordPress, Blogger...