天天看点

交叉编译OPENSSH(一)

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

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

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

一.服务器编译

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

 directories,  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  Could not load host key
Disabling protocol version  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::bf::::b1:b1:ab:e6:a:e1:d0::f: [email protected](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::f7:::f5:b5::::c:f4:fb:d:c: [email protected](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:
d:bb:b6::e::d3::d:e:e3::d:b7:: [email protected](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  /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 . LTS (GNU/Linux .--generic x86_64)

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

 packages can be updated.
 updates are security updates.

Last login: Wed Nov  ::  from .
root@inspur:/home/liufei#