交叉编译OPENSSH(一)

注:本文参考《http://blog.csdn.net/ke123456le/article/details/39316607》有增减。

本文分两部分,第一部分介绍目标文件编译以及目标板上的一些操作要求,第二部分介绍交叉编译脚本介绍(交叉编译OPENSSH(二))。

第一部分:目标文件编译以及目标板上的一些操作要求

一.服务器编译

  • 下载指定的文件,并建立如下目录结构:
root@test:/home/liufei/github/shell/openssh# tree .
.
├── compressed
│   ├── openssh-4.6p1.tar.gz
│   ├── openssl-0.9.8l.tar.gz
│   ├── startWork.sh-openssh
│   ├── startWork.sh-openssl
│   ├── startWork.sh-zlib
│   ├── uncompress.sh
│   └── zlib-1.2.8.tar.gz
└── source

3 directories, 7 files
root@test:/home/liufei/github/shell/openssh# 
  • 在/home/liufei/github/shell/openssh下执行如下指令,等待编译完成
./uncompress.sh /home/liufei/github/shell/openssh/compressed ../source  /root/openssh mipsel-linux

二.目标板操作

1、将主机/root/openssh中的所有内容全部复制到目标板上的/root/openssh目录下

2、生成证书/密码对(注:仅需一次)
A、运行一下sshd

# /root/openssh/sbin/sshd 
Could not load host key: /root/openssh/etc/ssh_host_key
Could not load host key: /root/openssh/etc/ssh_host_rsa_key
Could not load host key: /root/openssh/etc/ssh_host_dsa_key
Disabling protocol version 1. Could not load host key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.

B、在目标板上,键入如下指令

# pwd
/etc/createkey
# ls
# /root/openssh/bin/ssh-keygen -t rsa1 -f ssh_host_key -N ""&&/root/openssh/bin
/ssh-keygen -t rsa -f ssh_host_rsa_key -N ""&&/root/openssh/bin/ssh-keygen -t d
sa -f ssh_host_dsa_key -N ""
Generating public/private rsa1 key pair.
Your identification has been saved in ssh_host_key.
Your public key has been saved in ssh_host_key.pub.
The key fingerprint is:
f8:80:bf:56:05:78:b1:b1:ab:e6:7a:e1:d0:69:4f:34 root@(none)
Generating public/private rsa key pair.
Your identification has been saved in ssh_host_rsa_key.
Your public key has been saved in ssh_host_rsa_key.pub.
The key fingerprint is:
b7:42:f7:55:91:f5:b5:56:65:91:4c:f4:fb:4d:5c:70 root@(none)
Generating public/private dsa key pair.
Your identification has been saved in ssh_host_dsa_key.
Your public key has been saved in ssh_host_dsa_key.pub.
The key fingerprint is:
3d:bb:b6:83:4e:71:d3:51:3d:3e:e3:77:2d:b7:27:42 root@(none)
# ls
ssh_host_dsa_key      ssh_host_key          ssh_host_rsa_key
ssh_host_dsa_key.pub  ssh_host_key.pub      ssh_host_rsa_key.pub
# 

C、将生成的文件,全部放到目标板目录/root/openssh/etc/

3、修改启动脚本

A、修改root密码&&创建ssh用户

#将原有的root密码删除
echo "create root passwd."
cat /etc/passwd | sed '1d' > /tmp/passwd
mv /tmp/passwd /etc/passwd

#将新密码设置为passwd 123456, use busybox
echo "root:wAYUOfP1kjXRw:0:0:root:/root:/bin/sh">>/etc/passwd

#创建ssh用户,主要是解决Privilege separation user sshd does not exist
echo "create user sshd to /etc/passwd."
echo "sshd:x:110:65534::/var/run/sshd:/usr/sbin/nologin">>/etc/passwd

B、创建/var/empty

#sshd运行时需要,否则会报Missing privilege separation directory: /var/empty
echo "create /var/empty."
mkdir -p /var/empty
chmod 755 /var/empty

C、后台运行sshd

#echo "now run sshd"
/root/openssh/sbin/sshd  &

4、ssh测试

# pwd
/root/openssh/bin
# ls
c_rehash     scp          slogin       ssh-add      ssh-keygen
openssl      sftp         ssh          ssh-agent    ssh-keyscan
# ssh 10.180.91.55
Could not create directory '/root/.ssh'.
The authenticity of host '10.180.91.55 (10.180.91.55)' can't be established.
RSA key fingerprint is 72:3f:a4:18:d3:55:e2:09:66:15:c9:0b:08:6a:b6:a8.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/root/.ssh/known_hosts).
[email protected]'s password: 
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

428 packages can be updated.
241 updates are security updates.

Last login: Wed Nov 23 14:03:37 2016 from 192.168.56.18
root@inspur:/home/liufei# 

你可能感兴趣的:(shell)