Enabling SSH on ASUS RT-N56U Router

Categories: Development NotesLinux; Tagged with: ; @ May 15th, 2016 15:36

the default firmware doesn’t provide the SSH feature, however, with the help of padavan‘s rt-n56u project, you may enable it:

This project aims to improve the rt-n56u and other supported devices on the software part, allowing power user to take full control over their hardware. This project was created in hope to be useful, but comes without warranty or support. Installing it will probably void your warranty. Contributors of this project are not responsible for what happens next.

How do I get set up?

What I did:

  1. download RT-N56U_3.4.3.9-099_base.trx
  2. login to the router setting dashboard, and upgrade the firmware by selecting the downloaded file.
  3. after couple minutes,  my router reset, I connect to the router via cable, and setup wifi. (you may try ‘1234567890’ to connect to your wifi network if you cannot connect to it directly)
  4. login to the router setting dashboard, you’ll find a new UI! navigate to: Advanced Settings > Administration > Services to setup your ssh server.  more details: https://bitbucket.org/padavan/rt-n56u/wiki/EN/CommonTips

ssh to linux guest/virtual machine running virtualbox

Categories: Linux; Tagged with: ; @ January 23rd, 2016 16:07

Install / Start SSH in your guest Linux

sudo service ssh status

install open-ssh in case it’s not ready in your guest:

sudo apt-get install openssh-server

start the service if the service is stopped.

sudo service ssh start

Setup VirtualBox – port forwarding

virtualbox > edit settings for the guest vm:
network > port forwarding (e.g host 3022 -> guest 22)

SSH to the guest linux

ssh user@loalhost -p 3022

Online SSH Client from C9.io

Categories: Development NotesLinux; Tagged with: ; @ March 23rd, 2014 1:14

Access your server via. online https SSH Client: https://c9.io



Btw, C9’s online IED is awesome,  take a look it’s html editor:


Spirng3.1 + Hibernate4.1 HelloWorld

Categories: Java; Tagged with: ; @ June 24th, 2012 23:20

Here is a simple example about configuration of Spring3 and Hibernate4.

1. We need define a sessionFactory bean:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost/mini-liguoliang.com" />
    <property name="username" value="root" />
    <property name="password" value="password" />

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="packagesToScan" value="com.liguoliang.spring.po"></property>
    <property name="hibernateProperties">
            <prop key="dialect">org.hibernate.dialect.MySQLDialect</prop>

<context:component-scan base-package="com.liguoliang.spring"></context:component-scan>

Basically, we did there things:

  1. Define the datasource;
  2. define the session factory, we need specify the packagesToScan property, this property will scan all entity annotated class.
  3. define the context component-scan basepackage, this will scan all @Repository annotated Class, like the dao class in 4.

2. Define the Entity Class:

package com.liguoliang.spring.po;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

public class User {
	@javax.persistence.Id @GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	private String name;
	private String login_name;
	public String getLogin_name() {
		return login_name;
	public void setLogin_name(String login_name) {
		this.login_name = login_name;
	public String getName() {
		return name;
	public void setName(String name) {
		this.name = name;
	public int getId() {
		return id;
	public void setId(int id) {
		this.id = id;
	public String toString() {
		return "User - " + name + " [" + id + "]";


Note the annotation: @Entity

3. We have a table related to this entity:


4. In the dao class:

package com.liguoliang.spring;

import java.io.File;
import java.util.Date;

import javax.persistence.Entity;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate4.SessionFactoryUtils;
import org.springframework.stereotype.Repository;

import com.liguoliang.spring.po.User;
public class UserHibernateDAO {
	private SessionFactory sessionFactory;
	public UserHibernateDAO(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	public User getUserByID(int id) {
		Session session = SessionFactoryUtils.openSession(sessionFactory);
		return (User) session.get(User.class, id);

5.  Communicate with database using DAO

We need a hibernateBean instance:

package com.liguoliang.spring.web;

public class ControllerUser {
	private UserHibernateDAO userHibernateDAO;
	@RequestMapping(value={"", "list"})
	public String list(Model model) {
		// We just print the user info in the console.	
		System.out.println("userName: " + userHibernateDAO.getUserByID(10).toString());

		return "userList";

When list() is called, user with the id ’10’ will be loaded by the hibernateDAO, and printed in the console.

6. Related pattern – Data Access Object


Figure 9.2
Figure 9.2 Data Access Object sequence diagram


The BusinessObject represents the data client. It is the object that requires access to the data source to obtain and store data. A BusinessObject may be implemented as a session bean, entity bean, or some other Java object, in addition to a servlet or helper bean that accesses the data source.


The DataAccessObject is the primary object of this pattern. The DataAccessObject abstracts the underlying data access implementation for the BusinessObject to enable transparent access to the data source. The BusinessObject also delegates data load and store operations to the DataAccessObject.


This represents a data source implementation. A data source could be a database such as an RDBMS, OODBMS, XML repository, flat file system, and so forth. A data source can also be another system (legacy/mainframe), service (B2B service or credit card bureau), or some kind of repository (LDAP).


This represents a Transfer Object used as a data carrier. The DataAccessObject may use a Transfer Object to return data to the client. The DataAccessObject may also receive the data from the client in a Transfer Object to update the data in the data source.

// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.