1 Teleport简介node
https://docs.tp4a.com/ python
Teleport是一款简单易用的堡垒机系统,具备小巧、易用的特色,支持 RDP/SSH/SFTP/Telnet 协议的远程链接和审计管理。mysql
Teleport由两大部分构成:linux
跳板核心服务web
WEB操做界面sql
支持的操做系统(服务端)数据库
Teleport支持部署到Linux系统中,目前支持的系统版本以下:vim
Ubuntu 14.04 64位 及以上版本centos
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
浏览器打开上面地址 选择一个版本下载,下载后上传到服务器上
这里下载的是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: apex.liu@qq.com | []===========================================================================[] 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
这里 使用默认的数据库,更改帐户密码---填写邮箱和新密码---开始配置
再次刷新--登录
3.2主机管理
点击添加主机按钮添加单台主机或者根据导入模版批量添加主机
添加帐号
3.3测试链接,须要window安装客户端
安装下载teleport客户端
安装后从新链接ssh
选择y 而后再点击页面ssh链接
其余页面功能配置,能够参考
http://www.javashuo.com/article/p-kkktayub-hd.html
-----------------------------
注: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能够远程登陆,删除匿名用户等等
设置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.
刷新登陆界面
其余使用请参考https://docs.tp4a.com/