# Teltport 堡垒机部署

#### 博客作者：联系请[点击](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)，搬运不易，希望请作者喝咖啡，可以点击联系[博客作者](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)

## 1.引言

### 1.1 编写目的

Teleport是一款简单易用的堡垒机系统，具有小巧、易用的特点，支持 RDP/SSH/SFTP/Telnet 协议的远程连接和审计管理。

Teleport由两大部分构成：

* 跳板核心服务
* WEB操作界面

## 2.部署对象说明

### 2.1 程序名称

* Teleport 有两个服务：核心服务 core 和网页服务 web。两个服务可以同时启动、停止、重启，也可单独操作其中的一个。

### 2.2 程序功能

* Teleport支持 RDP/SSH/SFTP/Telnet 协议的远程连接和审计管理。

### 2.3 程序启动与停止

操作完整的 teleport 服务：

* 启动： /etc/init.d/teleport start
* 停止： /etc/init.d/teleport stop
* 重启： /etc/init.d/teleport restart
* 查看运行状态： /etc/init.d/teleport status

仅操作核心服务 core：

* 启动： /etc/init.d/teleport start core
* 停止： /etc/init.d/teleport stop core
* 重启： /etc/init.d/teleport restart core

仅操作网页服务 web：

* 启动： /etc/init.d/teleport start web
* 停止： /etc/init.d/teleport stop web
* 重启： /etc/init.d/teleport restart web

## 3.部署操作

### 3.1 环境准备

**支持的操作系统（服务端）**

Teleport支持部署到Linux系统中，目前支持的系统版本如下：

* Ubuntu 14.04 64位 及以上版本
* CentOS 7.0 64位 及以上版本
* Debian 6.0 64位 及以上版本
* Redhat 6.2 64位 及以上版本

**支持的操作系统（客户端）**

* Windows
* MacOS

**依赖环境**

因为Teleport内建了所需的脚本引擎、WEB服务等模块，因此不需要额外安装其他的库或者模块，整个系统的安装与部署非常方便。

官方安装文档：

{% embed url="<https://docs.tp4a.com>" %}

源码官方网站：

{% embed url="<https://github.com/tp4a/teleport>" %}

### 3.2 安装步骤

**yum安装本次环境搭建所需依赖**

```
yum -y install git vim lrzsz createrepo epel-release yum-utils
```

[Teltport官方网站 tar包下载](https://www.tp4a.com/download/get-file/teleport-server-linux-x64-3.2.2.tar.gz)

![](/files/-LxUKEpbl99g-HmR2nTn)

下载完传送到服务器上

```
tar -zvxf teleport-server-linux-x64-3.2.2.tar.gz
cd teleport-server-linux-x64-3.2.2
./setup.sh
```

安装时需要指定安装路径，您可以使用默认的安装路径/usr/local/teleport（直接回车即可），也可以指定别的路径，请注意**路径中不要含有中文字符或空格**，以避免出现不可预知的错误。默认的录像回放文件位于/usr/local/teleport/data/replay目录下，会占用/usr的空间，因此建议安装完成后[配置录像回放文件的存储路径](https://docs.tp4a.com/config/%22%20/l%20%22replay-path)。

![](/files/-LxUKEpcO64K5Yha8Fxm)

仅需几秒钟，安装就完成了，堡垒机的核心服务和WEB服务均已自动启动。

您可以访问<http://teleport服务器IP:7190/来进行初始化设置。>

{% hint style="danger" %}

#### 注意：访问之前关闭防火墙

{% endhint %}

```
systemctl stop firewalld.service
```

### **3.3 录像文件存放路径 replay-path**

因为在teleport服务工作过程中，占用磁盘空间较大的是录像回放文件，容易导致 /usr 空间不足，因此可以根据需要将录像文件存放到别的挂载的磁盘上。可以通过修改 replay-path 来进行设定。

添加MySQL Yum存储库

官方下载网站：

{% embed url="<https://dev.mysql.com/downloads/repo/yum/>" %}

```
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
```

```
createrepo .         #在当前目录生成yum仓库，此时文件夹中多了repodata目录，说明自定义yum仓库创建成功
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum update mysql     #更新MySQL yum 依赖仓库
yum repolist all | grep mysql     #查看MySQL Yum存储库中的所有子存储库，并查看哪些子存储库已启用或禁用
yum-config-manager --disable mysql80-community       #禁用8.0系列的子存储库
yum-config-manager --enable mysql57-community        #启用5.7系列的子存储库
```

{% hint style="danger" %}
注：也可手动修改yum配置文件vim /etc/yum.repos.d/mysql-community.repo，把相对应版本的enabled=0修改为enabled=1，1表示开启这个存储库，0表示关闭。
{% endhint %}

### 3.4 安装数据库

```
yum install mysql-community-server
systemctl start mysqld && systemctl enable mysqld
grep "password" /var/log/mysqld.log
```

![](/files/-LxUKEpd-OMaIZ9NRLnD)

```
mysqladmin -uroot -p"j2hb=2.gobpQ" password "输入设置的密码"  #修改数据库初始密码
```

### **3.5 连接MySQL创建远程授权用户和库**

Teleport支持MySQL数据库（当然也支持MariaDB）。这里以MySQL为例进行说明。

要使用MySQL数据库，需要先为teleport创建库并授权。

以MySQL数据库的管理员身份在命令行工具中执行：

{% hint style="danger" %}
**注意：数据库的字符集必须是 utf-8 ，否则会出现乱码，或者初始化表数据时会失败。**
{% endhint %}

```
mysql -uroot -p
> create database teleport default character set utf8 collate utf8_general_ci;
> grant all privileges on teleport.* to teleport@127.0.0.1 identified by '密码';
> flush privileges;         #更新权限表
```

![](/files/-LxUKEpeMdQmtmnAZeZf)

请注意表名、用户名与密码等要与 web.ini 中的设置一致。

```
vim /usr/local/teleport/data/etc/web.ini
```

![](/files/-LxUKEpfngF1tRCZQYr_)

修改 web.ini，去掉 ; type=sqlite 前面的注释符号，并改为 type=mysql。

## 4. 初始化配置

您需要在这里设置系统管理员的账号和密码，此账号具有系统的最高权限，请务必牢记密码。设置完成后，点击“开始配置”按钮即可完成初始配置工作了：

![](/files/-LxUKEpgxe0vLkwoXkx-)

初始化配置完成后，刷新页面即可进入teleport的登录界面。

![](/files/-LxUKEphYbdUWgAnu1JX)

### 4.1 添加主机

![](/files/-LxUKEpi4UjORdE6ZnIL)

### 4.2 创建用户账号

![](/files/-LxUKEpjR8rQssYxyt7b)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hezhiqiang.gitbook.io/about-the-author/yun-wei-huan-jing-da-jian/untitled-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
