Application Notes - How To Port SSH to iMX6Q Development Board

This article is based on Forlinx development board: OKMX6Q/OKMX6DL-C SBC. This series uses i.MX6Q/DL processors. The system for demonstrating is linux3.0.35. For dev boards of other brands, please refer to use. This article introduces how to install SSH on iMX6Q development board. Any materials and information provided in this article are for informational purposes only.

1. Build server

First, build server in virtual machine.

Install SSH as follows:

  • Execute cd / in virtual machine to switch to directory: root
  • Execute apt-get install yum, and then execute apt-get install ssh
  • Execute ufw disable to turn off firewall
  • Start server and execute /etc/init.d/ssh start

2. Install SSH client on dev board

Porting openssh to iMX6Q dev board completes the work of installing SSH client.

a. Install cross compiler

The cross compiler here is arm-none-linux-gnueabi-gcc, which can be obtained from user profile of SBC OKMX6Q/OKMX6DL-C. Copy it to /usr/local/arm of virtual machine and unzip it. Add another line at the end of /etc/profile file, and enter:

export PATH=/usr/local/arm/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/bin:$PATH

Save and exit, and execute source /etc/profile in terminal. This will make the environment variable take effect without restarting system.

To check if the installation is successful, execute arm-fsl-linux-gnueabi-gcc –v in terminal

Check whether cross compiler is installed successfully.


b. Download source package

Download three source packages: openssh-4.6p1.tar.gz, openssl-0.9.8k.tar.gz and zlib-1.2.3.tar.gz. The ssh service needs zlib and ssl libraries support.

Note: The version mentioned above is recommended. Some file updates in higher versions may have installation problems.


c. Cross compiling

Build directory structure /EmbSSH

Compressed is to store source packages,

install is software installation directory,

source is decompression directory of source packages.

Put openssh-4.6p1.tar.gz, openssl-0.9.8k.tar.gz, zlib-1.2.3.tar.gz in directory: compressed

cross compile zlib

cd /EmbSSH/compressed/ 
tar xvf zlib-1.2.3.tar.gz -C ../source 
cd ../source/zlib-1.2.3 
./configure --prefix=/EmbSSH/install/zlib-1.2.3 

Modify the following information in Makefile

CC=arm-none-linux-gnueabi-gcc

AR= arm-none-linux-gnueabi-ar rc

CPP = arm-none-linux-gnueabi-gcc -E

LDSHARED= arm-none-linux-gnueabi-gcc

Execute

make

make install

cross compile openssl
cd /EmbSSH/compressed/ 
tar zxvf openssl-0.9.8e.tar.gz -C ../source 
cd ../source/openssl-0.9.8e 
./Configure --prefix=/EmbSSH/install/openssl-0.9.8e 
os/compiler: arm-none-linux-gnueabi-gcc 
make 
make install

cross compile openssh 
cd /EmbSSH/compressed 
tar zxvf openssh-4.6p1.tar.gz C ../source 
cd ../source/openssh-4.6p1 
./configure --host=arm-linux --with-libs --with-zlib=/EmbSSH/install/zlib-1.2.3 
--with-ssl-dir=/EmbSSH/install/openssl-0.9.8e 
--disable-etc-default-login 
CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar

Output information as following:

OpenSSH has been configured with the following options:

User binaries: /usr/local/bin

...

Linker flags: -L/EmbSSH/install/openssl-0.9.8e/lib

-L/EmbSSH/install/zlib-1.2.3/lib

Libraries: -lresolv -lcrypto -lutil -lz -lnsl -lcrypt

Execute make, and don’t execute make install

Now, the files to be compiled have been completed.


3. Install SSH on iMX6 dev board

Create folders bin, etc, libexec, sbin in EmbSSH/source/openssh-4.6p1 of virtual machine

mkdir -p EmbSSH/source/openssh-4.6p1/{bin,etc,libexec,sbin}

Generate key file

cd /EmbSSH/source/openssh-4.6p1 
ssh-keygen -t rsa1 -f ssh_host_key -N "" 
ssh-keygen -t rsa -f ssh_host_rsa_key -N "" 
ssh-keygen -t dsa -f ssh_host_dsa_key -N ""

Copy the compiled target file scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan in /EmbSSH/source/openssh-4.6p1 to bin.

Copy moduli ssh_config sshd_config and generated key file to etc.

Copy sftp-server ssh-keysign to libexec.

Copy sshd to sbin.

cp scp sftp ssh ssh-add ssh-agent 
ssh-keygen ssh-keyscan ../../source/openssh-4.6p1/bin/ 
cp moduli ssh_config sshd_config ../../ source/openssh-4.6p1/etc 
cp sftp-server ssh-keysign ../../ source/openssh-4.6p1/libexec/ 
cp sshd ../../ source/openssh-4.6p1/sbin 
cp ssh_host_*_key ../../ source/openssh-4.6p1/etc

Package the well-placed images

cd /EmbSSH/ source/openssh-4.6p1/

tar zcvf openssh.tar.bz2 ./*

Copy the compressed package openssh.tar.bz2 to iMX6Q dev board through USB disk, and extract it to usr/local of iMX6Q dev board

tar xvf openssh.tar.bz2 -C /usr/local

And, create an empty folder on dev board:

mkdir /var/empty

Start ssh service

/usr/local/sbin/sshd

The following error may appear

root@freescale /$ /usr/local/sbin/sshd

Could not load host key: /usr/local/etc/ssh_host_dsa_key

Disabling protocol version 1. Could not load host key

At this point, regenerate hostkey file and place it under /usr/local/etc

ssh-keygen -t rsa1 -f ssh_host_key -N ""

cp ssh_host_dsa_key ./usr/local/etc/

cp ssh_host_dsa_key.pub ./usr/local/etc/

Restart ssh service

/usr/local/sbin/sshd

Now, you can use ssh client to connect to iMX6Q dev board.