Tuesday, 8 December 2015

How to insert a section of code in Blogger easily




Insert this section of in HTML View:

<ol start="1" style="background-color: white; border: none; color: #5c5c5c; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; line-height: 26px; margin: 0px 0px 1px 45px !important; padding: 0px;">
<li class="alt" style="border-left-color: rgb(108, 226, 108); border-left-width: 3px; border-style: none none none solid; color: inherit; line-height: 18px; list-style: decimal-leading-zero outside; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;">The First line</span></li>
<li class="" style="background-color: #f8f8f8; border-left-color: rgb(108, 226, 108); border-left-width: 3px; border-style: none none none solid; line-height: 18px; list-style: decimal-leading-zero outside; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;">The second Line</span></li>
<li class="alt" style="border-left-color: rgb(108, 226, 108); border-left-width: 3px; border-style: none none none solid; color: inherit; line-height: 18px; list-style: decimal-leading-zero outside; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;">The Third Line;</span></li>
</ol>

(In order to avoid confusing, I just past html code here without code format.  )

Then the page would show as this in Compose View:

  1. The First line
  2. The second Line
  3. The Third Line;


Use it as a template, you can edit, delete, copy and past in Compose View:


  1. The 1st line
  2. The 2nd Line
  3. The 3rd Line

  4. The 4th Line


Of course the code at beginning of this article can show like this

  1. <ol start="1" style="background-color: white; border: none; color: #5c5c5c; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; line-height: 26px; margin: 0px 0px 1px 45px !important; padding: 0px;">
  2. <li class="alt" style="border-left-color: rgb(108, 226, 108); border-left-width: 3px; border-style: none none none solid; color: inherit; line-height: 18px; list-style: decimal-leading-zero outside; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;">The First line</span></li>
  3. <li class="" style="background-color: #f8f8f8; border-left-color: rgb(108, 226, 108); border-left-width: 3px; border-style: none none none solid; line-height: 18px; list-style: decimal-leading-zero outside; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;">The second Line</span></li>
  4. <li class="alt" style="border-left-color: rgb(108, 226, 108); border-left-width: 3px; border-style: none none none solid; color: inherit; line-height: 18px; list-style: decimal-leading-zero outside; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;">The Third Line;</span></li>
  5. </ol>

Thursday, 26 November 2015

scp/login ssh server without password

There are 2 ways to log in ssh server
* Typing password on login
* public key authentication
Both method can be deployed in same ssh server. Public Key Authentication is the topic here.



1. Generate public key and private key

A Lock(public key) and a Key(private key) has to be generated first. 
The way to generate:
(my ssh client is command "ssh" running from an Ubuntu 14.04LTS)
james@james-PC ~/.ssh $ ssh-keygen
  1. Generating public/private rsa key pair.  
  2. Enter file in which to save the key (/home/james/.ssh/id_rsa): /tmp/my_keys  
  3. Enter passphrase (empty for no passphrase):   
  4. Enter same passphrase again:   
  5. Your identification has been saved in /tmp/my_keys》.  
  6. Your public key has been saved in /tmp/my_keys.pub.  
  7. The key fingerprint is:  
  8. e0:78:ef:88:51:41:e1:71:e9:fc:b1:95:e1:c5:d8:e6 james@james-PC  
  9. The key's randomart image is:  
  10. +--[ RSA 2048]----+  
  11. |      +...   +   |  
  12. |     o o.   o =  |  
  13. |      +o   . *   |  
  14. |     o oo . + E  |  
  15. |    . + S. +     |  
  16. |     o .  o      |  
  17. |    .   .        |  
  18. |     o o         |  
  19. |    . . .        |  
  20. +-----------------+  
The passphrase prompted here is not for ssh server authentication. It is for protection the Key (private key) itself. You may type enter directly to assign a empty passphrase, then there would be no passphrase prompted when you login with this Key(private key). Of course a string with more than 4 characters can be typed  to protect your Key(private key). 
There is no protection of the Lock, the public key.


The output of the command is the Lock(public key) and the key(private key):
  1. james@james-PC ~/.ssh $ ls /tmp/ -l  
  2. total 148  
  3. -rw------- 1 james james   1766 Nov 25 17:05 my_keys  
  4. -rw-r--r-- 1 james james    421 Nov 25 17:05 my_keys.pub  
Here,content of my_keys is the Ke(private key), while content of my_keys.pub is the lock(public key).


2. Insert public key into ssh server

Ssh server needs this Lock to verify your Key.Suppose the name of ssh server is "ssh-server".
Simply append the content of my_keys.pub to the end of file authorized_keys which is located at .ssh/authorized_keys of the correspond user's home directory. Copy can be done by scp, ftp, ... even usb-disk.

  1. scp /tmp/my_keys.pub james@ssh-server:/home/james/.ssh/authorized_keys  

To make it simple, the file is just overwrites the target which would cause the lost of other public key.

3. Test

Ssh server would verify your Key (private key) with the Lock (public key) which is provided when you login:
  1. ssh james@ssh-server  
Nothing need by typed here if you assigned empty passphrase when creating the keys, or you have to type the passphrase that is same to the one when the keys was generated.