以下是基于Ubuntu系统搭建堡垒机并集成设备管理的详细步骤和注意事项:
一、堡垒机搭建步骤
sudo apt update && sudo apt upgrade -y
sudo apt install openssh-server fail2ban ufw -y
# 修改SSH端口
sudo sed -i 's/#Port 22/Port 58222/' /etc/ssh/sshd_config
# 禁用root登录
sudo sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
# 配置防火墙
sudo ufw allow 58222/tcp
sudo ufw enable
sudo systemctl restart sshd
curl https://deb.releases.teleport.dev/teleport-pubkey.asc | sudo apt-key add -
echo "deb https://deb.releases.teleport.dev/ stable main" | sudo tee /etc/apt/sources.list.d/teleport.list
sudo apt update
sudo apt install teleport
sudo teleport configure -o /etc/teleport.yaml
sudo systemctl enable teleport
sudo systemctl start teleport
二、设备接入配置
ssh-keygen -t rsa -b 4096 -C "bastion_admin"
ssh-copy-id -i ~/.ssh/id_rsa.pub admin@server1 # 维护服务器
enable
configure terminal
ip domain-name example.com
crypto key generate rsa modulus 2048
line vty 0 4
transport input ssh
access-class 100 in
exit
ip access-list standard 100
permit host 192.168.1.100 # 堡垒机IP
exit
config system admin
edit "teleport_admin"
set ssh-public-key1 "ssh-rsa AAAAB3NzaC1yc2E..."
set trusthost1 192.168.1.100/32
set accprofile "super_admin"
next
end
三、访问Teleport Web控制台
# 查看Teleport服务状态获取访问地址(默认使用3080端口)
sudo teleport status
输出示例:
Cluster Name: teleport.example.com
Version: 13.0.0
Hostname: bastion-server
Web UI: https://bastion-server:3080
https://:3080
首次访问需忽略证书警告或提前部署合法证书
首次登录需通过CLI获取初始令牌:
sudo tctl users add teleport-admin --roles=editor,access
按提示设置密码后完成登录
四、网页端添加服务器设备
- 导航到「节点」管理
- 左侧菜单栏 → Infrastructure → Servers → Add Server
- 填写服务器信息
Hostname: web-server-01
IP Address: 192.168.1.101
Port: 22 (默认SSH端口)
Labels:
env=production
role=webserver
# 在堡垒机上生成并分发密钥
sudo tctl auth sign --format=openssh --user=teleport-admin --host=web-server-01
- 手动密钥上传:粘贴~/.ssh/teleport-admin.pub公钥内容
- 测试连接
- 点击 Verify Connection 进行连通性测试
- 成功标志:显示绿色 "Node is reachable" 提示
五、添加网络设备(Cisco交换机为例)
line vty 0 4
transport input ssh
login local
- Web界面操作
- 导航至 Infrastructure → Networking Devices → Add Device
Device Type: Cisco Switch
Management IP: 192.168.1.200
Protocol: SSHv2
Port: 22
Credentials:
Type: SSH Key
Username: cisco-admin
Private Key: [上传预先创建的专用密钥]
- 高级配置
- 开启 Session Recording 启用操作审计
- 设置命令过滤规则(示例禁止配置删除):
# 在Teleport策略文件添加
spec:
deny:
- "clear configuration"
- "delete flash:*"
六、添加安全设备(以FortiGate防火墙为例)
config system api-user
edit "teleport-user"
set accprofile "super_admin"
set vdom "root"
config trusthost
edit 1
set ipv4-trusthost 192.168.1.100/32
next
end
set api-key generate
end
- Web界面配置
- 导航至 Infrastructure → Security Devices → Add Firewall
Vendor: Fortinet
API Endpoint: https://192.168.1.150:443
API Key: xxxxxxxxxxxxxxxxx (从防火墙获取的API密钥)
Sync Interval: 300 (秒自动同步策略)
kind: role
version: v5
metadata:
name: firewall-operator
spec:
allow:
firewall_actions: ["get","list"]
deny:
- "execute reboot"
七、添加IDS/IPS设备(以Suricata为例)
# 在Suricata服务器配置日志转发
sudo tee -a /etc/suricata/suricata.yaml /backup/teleport-db-$DATE.sql
aws s3 cp /backup/*-$DATE.* s3://your-bucket/backups/
sudo crontab -e
# 每天凌晨2点执行备份
0 2 * * * /usr/local/bin/teleport_backup.sh
# 每月执行恢复测试
tar -tf /backup/teleport-config-latest.tar.gz
mysql -u root -p -e "DROP DATABASE teleport; CREATE DATABASE teleport;"
mysql -u root -p teleport < /backup/teleport-db-latest.sql
十二、高级安全设置
# 创建管理VLAN
sudo apt install vlan
sudo modprobe 8021q
sudo vconfig add eth0 100
sudo ip addr add 192.168.100.1/24 dev eth0.100
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/wazuh.gpg --import
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | sudo tee /etc/apt/sources.list.d/wazuh.list
sudo apt update
sudo apt install wazuh-agent
十三、故障排查命令
mtr -rw 192.168.1.1 # 实时路由跟踪
tshark -i eth0 -Y "ssh" -f "tcp port 58222" # SSH流量分析
# 安装Prometheus监控
sudo apt install prometheus-node-exporter
sudo systemctl enable prometheus-node-exporter
建议每月执行安全审计:
lynis audit system
rkhunter --check
以上方案实现了基于角色的精细化管理,所有管理操作均通过加密隧道进行,审计日志保留周期建议不低于180天。关键设备建议采用证书+动态令牌双因素认证,网络设备配置变更需通过堡垒机审批流程。
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |