堡垒机teleport之旅

1 Teleport简介

https://docs.tp4a.com/

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

    Teleport由两大部分构成:

        跳板核心服务

        WEB操作界面

    支持的操作系统(服务端)

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

        Ubuntu 14.04 64位 及以上版本

        CentOS 6.2 64位 及以上版本

        Debian 6.0 64位 及以上版本

        Redhat 6.2 64位 及以上版本

    支持的操作系统(客户端)

        Windows

        MacOS

2 teleport部署测试

2.1系统环境准备

安装centos7.2系统,最小化安装

设置好网络和防火墙  网络需要能访问外网,

ip 192.168.0.190

下面关闭防火墙

setenforce 0

systemctl stop firewalld

systemctl disable firewalld

sed -i 's/enforcing/disabled/g' /etc/sysconfig/selinux


设置yum源

cd /etc/yum.repos.d/

yum install vim unzip lrzsz wget net-tools -y

wget http://mirrors.aliyun.com/repo/Centos-7.repo

wget http://mirrors.aliyun.com/repo/epel-7.repo

yum -y install epel-release


2.3下载安装teleport

https://www.tp4a.com/download

浏览器打开上面地址 选择一个版本下载,下载后上传到服务器上

这里下载的是teleport-server-linux-x64-3.1.0.tar.gz这个版本

tar zxf teleport-server-linux-x64-3.1.0.tar.gz
 cd teleport-server-linux-x64-3.1.0
 ./setup.sh

使用默认的安装路径/usr/local/teleport(直接回车即可)

[root@localhost teleport-server-linux-x64-3.1.0]# ./setup.sh 

[]===========================================================================[]
 | Teleport Server Installation                                              |
 |===========================================================================|
 |    ver: 3.1.0                                                             |
 | author: [email protected]                                                   |
[]===========================================================================[]

Welcome to install Teleport Server!

NOTICE: There are a few steps need you enter information or make choice,
        if you want to use the DEFAULT choice, just press `Enter` key.
        Otherwise you need enter the highlight character to make choice.


Prepare installation...
 - check local installation ... [not exists]


Set installation path [/usr/local/teleport]: 
 - copy [/usr/src/teleport-server-linux-x64-3.1.0/data/bin]
     -> [/usr/local/teleport/bin]
 - copy [/usr/src/teleport-server-linux-x64-3.1.0/data/www]
     -> [/usr/local/teleport/www]
 - copy [/usr/src/teleport-server-linux-x64-3.1.0/data/tmp/etc]
     -> [/usr/local/teleport/data/etc]
process [daemon.in] to [/etc/init.d/teleport]
process [start.sh.in] to [/usr/local/teleport/start.sh]
process [stop.sh.in] to [/usr/local/teleport/stop.sh]
process [status.sh.in] to [/usr/local/teleport/status.sh]

start services...
starting teleport web ... [done]
starting teleport core server ... [done]

check services status...
teleport web server is running.
teleport core server is running.

--==[ ALL DONE ]==--
启动命令
Teleport服务的启动与停止
启动teleport服务:
# /etc/init.d/teleport start
停止teleport服务:
# /etc/init.d/teleport stop
重新启动teleport服务:
# /etc/init.d/teleport restart
查看Teleport服务的运行状况:
# /etc/init.d/teleport status

配置文件
可以根据需要修改
# /usr/local/teleport/data/etc/web.ini 
# /usr/local/teleport/data/etc/core.ini


3 管理配置teleport

安装就完成后,堡垒机的核心服务和WEB服务均已自动启动。

3.1浏览器可以访问http://192.168.0.190:7190/  来进行初始化设置。

默认密码admin/admin

图片.png

 这里 使用默认的数据库,更改账户密码---填写邮箱和新密码---开始配置

图片.png

再次刷新--登陆

图片.png

3.2主机管理

点击添加主机按钮添加单台主机或者根据导入模版批量添加主机

图片.png

添加账号

图片.png

3.3测试连接,需要window安装客户端

图片.png

安装下载teleport客户端

图片.png

安装后重新连接ssh

图片.png

选择y  然后再点击页面ssh连接

图片.png


其他页面功能配置,可以参考

https://blog.51cto.com/roben/2159970

https://docs.tp4a.com/


-----------------------------

注:admin密码忘记重置问题处理

admin密码忘记了,可以使用工具连接到机器上的sqlite3,修改tp_user表中的password字段,把字段修改为

3:19c9214f9a81ccfc:482ea1ad2859076539ca45b2b97eff266ec0473bea3dcee36f19b87f759d1535

然后重启应用即可  /etc/init.d/teleport restart
当连接sqlit3不方便时候,或者python-sqlite3不熟悉,可以使用了一个很暴力的方法 直接取出来teleport.db 用navicat直接修改这个db文件,
把tp_user的password字段更新成3:19c9214f9a81ccfc:482ea1ad2859076539ca45b2b97eff266ec0473bea3dcee36f19b87f759d1535   
然后再把db文件替换回去,重启应用 就可以使用admin/admin 登陆了

--------------------------------------------------------------------------------



4 使用mysql数据库替换内置的sqlite3

teleport默认使用了python内置的sqlit3数据库,为了使用更熟悉的数据库方便管理,这里选择用mysql数据库

(注意:这里是初始化环境替换,如果sqlite3已经使用很久了,需要将数据导出,并导入新建的mysql才行)


yum install -y mariadb mariadb-devel mariadb-server

systemctl start mariadb

systemctl enable mariadb

初始化设置账号密码

mysql_secure_installation

root初始密码为空 设置root可以远程登录,删除匿名用户等等

图片.png


设置mysql字符集

vim /etc/my.cnf 增加下面配置

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

vim /etc/my.cnf.d/client.cnf

增加default-character-set=utf8

[client]
default-character-set=utf8

vim /etc/my.cnf.d/mysql-clients.cnf
增加default-character-set=utf8

[mysql]
default-character-set=utf8

进入mysql查看上面配置的是否正确

MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";
[root@node3 ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)

+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database   | utf8_unicode_ci |
| collation_server     | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)

MariaDB [(none)]>


创建数据库及账号并赋权

MariaDB [(none)]> create user teleport@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> create database teleport;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on teleport.* to teleport@localhost identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on teleport.* to teleport@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>

5 配置teleport文件

mysql 用户名是teleport,密码是123456
配置文件的默认路径是/usr/local/teleport/data/etc/web.ini

vim /usr/local/teleport/data/etc/web.ini  修改下面内容。

[database]

; database in use, should be sqlite/mysql, default to sqlite.
type=mysql

; sqlite-file=/usr/local/teleport/data/db/teleport.db

mysql-host=127.0.0.1

mysql-port=3306

mysql-db=teleport

mysql-prefix=tp_

mysql-user=teleport

mysql-password=123456

重启teleport

[root@node3 ~]# /etc/init.d/teleport  restart
stoping teleport web ... done.
stoping teleport core server ... done.
starting teleport web ... [done]
starting teleport core server ... [done]
teleport web server is running.
teleport core server is running.

刷新登录界面

图片.png

图片.png


其他使用请参考https://docs.tp4a.com/



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章