堡壘機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/



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