---
title: "openssh"
author: "liming495"
date: "2014-04-08T12:16:09Z"
tags: []
categories: ["非技术"]
slug: "openssh"
draft: false
lastmod: "2014-04-08T15:11:05Z"
id: 2042009
url: "https://liming495.iteye.com/blog/2042009"
---

```

```

 

[OpenSSL](http://www.openssl.org/) 是一款开源的 [SSL](http://zh.wikipedia.org/zh-cn/SSL) 软件包，采用 SSL 的公开密钥技术，用于实现传输层的通信加密功能。OpenSSL 支持 Linux、Windows、BSD、Mac 等平台，功能强大，包含丰富的密码算法库，SSL 协议库和应用程序。

 

### 一、SSL 基本常识

 

#### 1.1、什么是 SSL？

 

安全套接层（Secure Sockets Layer，SSL）， 最初由 netscape 公司设计，建立在传输层的安全通信协议，采用公开密钥体系的证书认证方式来确保客户端和 SSL 服务器之间的通信安全。

 

#### 1.2、SSL 认证流程

 

SSL 客户端在 TCP 连接建立之后，发出一个消息（包含了客户端所支持的算法列表）给服务器端，然后服务器端返回一个数据包（确定了这次通信所需算法）和 SSL 服务器端的证书（包含了公钥）给客户端。客户端随后会用收到的公钥将消息加密再传送，该加密消息只能用 SSL 服务器端私钥解密，即便中途被截取也无法获知内容。

 

### 二、编译安装 OpenSSL

 

#### 2.1、准备工作

 

系统版本：Ubuntu-10.10-Server-I386  
更新源：apt-get update  
升级软件：apt-get upgrade  
更新系统：apt-get dist-upgrade

 

#### 2.2、查看OpenSSL版本

 

部分 Linux 系统已默认安装了 OpenSSL 0.9.8，特别是 VPS 一般都安装了。

 

```
1
```

```
openssl version -a
```

 

#### 2.3、安装基础编译环境

 

```
1
```

```
apt-get  install build-essential
```

 

#### 2.3、编译安装 Zlib 库

 

```
1
2
3
4
5
```

```
wget http://zlib.net/zlib-1.2.5.tar.gz
tar -zxf zlib-1.2.5.tar.gz
cd zlib-1.2.5/
./configure --prefix=/usr/local
make && make install
```

 

#### 2.4、卸载旧版本 OpenSSL

 

```
1
2
```

```
apt-get purge openssl
rm -rf /etc/ssl #删除配置文件
```

 

#### 2.5、编译与安装 OpenSSL

 

prefix 是安装目录，openssldir 是配置文件目录，另外建议安装两次，shared 作用是生成动态连接库。

 

```
1
2
3
4
5
6
7
8
```

```
wget ftp://ftp.openssl.org/source/openssl-1.0.0c.tar.gz
tar -zxf openssl-1.0.0c.tar.gz
cd openssl-1.0.0c/
./config  --prefix=/usr/local --openssldir=/usr/local/ssl
make && make install
./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
make clean
make && make install
```

 

 

```
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib2
```

 openssl