SlideShare a Scribd company logo
Building a Moat
actually,
a bastion server
What does it do?




Provides a secure, single point of entry to your
              application servers
Why do you care?
What’s it look like?



Service Requests     SSH
Bastion System Setup
         wget                          ruby*
                                                                    MySQL*
                             curl           postgresql*
xorg*
                                                         nginx          net-snmp-libs
               jasper-libs       Uninstall
telnet                          everything!                php*         automake


        *X11       monit                                  gcc           DNS Name Server
                                    Mail Server

                  ftp                                            neon
                                               *devel*
                                                                             finger
 fetchmail                 net-snmp-libs
Bastion System Setup


     install netcat
Bastion System Setup

update everything that remains!

          sudo yum upgrade
Bastion SSH Config
Change Port from 22
      Port 2222



      Disable password logins/auth
                  PasswordAuthentication no



                                Disable PAM
                                     UsePAM no
Bastion IPTABLES

                                             DENY!!!!!
/etc/sysconfig/iptables
...

*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [237:32957]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state ESTABLISHED -j ACCEPT
-A INPUT -m state --state INVALID -j DROP
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2222 -j ACCEPT
COMMIT
Bastion User
Create a secure user group
     sudo /usr/sbin/groupadd moat



Create a “keymaster”

    Generate and
 upload an SSH key
Other Users

 Generate ssh-keys, use passphrases!


sudo   /usr/sbin/useradd -G moat -m new_user
sudo   mkdir -p /home/new_user/.ssh
sudo   mv ~/.new_user_ssh.pub /home/new_user/.ssh/authorized_keys
sudo   chmod -R 700 /home/new_user/.ssh
sudo   chown -R new_user:new_user /home/new_user/.ssh
echo   Any_r@nd0m_p@55w04D | sudo passwd new_user --stdin
Protected Server
          Iptables
...

*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
...
-A INPUT -s <moat’s IP address> -p tcp -m tcp --dport 22 -j ACCEPT

# HTTP and HTTPS
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
COMMIT
SSH
  Proxy through moat to access remote machines
Host app001
 Hostname app-001.blackboxservers.com
 User app_user
 ProxyCommand ssh -q -p 2222 $MOAT_USER@moat-001.blackboxservers.com nc %h 22


To SSH, just export your name and go!
$> export MOAT_USER=george
$> ssh app001
george@app-001.blackboxservers.com's password:

More Related Content

PPT
Linux Server Start
PDF
Configuration of BIND DNS Server On CentOS 8
PDF
Configuration Firewalld On CentOS 8
PDF
Sistemas operacionais 8
PPTX
Presentation Linux Server setup Advance Networking
PDF
CentOS Server Gui Initial Configuration
PDF
Firewalld LAB
PDF
Ftp configuration in rhel7
Linux Server Start
Configuration of BIND DNS Server On CentOS 8
Configuration Firewalld On CentOS 8
Sistemas operacionais 8
Presentation Linux Server setup Advance Networking
CentOS Server Gui Initial Configuration
Firewalld LAB
Ftp configuration in rhel7

What's hot (20)

PDF
Configuration of NTP Server on CentOS 8
PPTX
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
PDF
PDF
DevOps Braga #6
PDF
Configuration of Smtp Server On CentOS 8
PDF
Configuration of SFTP Server on CentOS 8.pdf
PDF
Cloud Compt
PDF
CentOS Server CLI Configuration (Nmcli & Hosts)
PPTX
Introduction to Docker
PDF
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
PDF
nouka inventry manager
PDF
SELF 2014: PBI v10: Application Management Made Easy
PPTX
От sysV к systemd
PDF
Openvpn
PDF
Linux Kernel Parameter Tuning
PDF
Introduction to FreeNAS development by John Hixson
PDF
PPT
Glomosim
Configuration of NTP Server on CentOS 8
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
DevOps Braga #6
Configuration of Smtp Server On CentOS 8
Configuration of SFTP Server on CentOS 8.pdf
Cloud Compt
CentOS Server CLI Configuration (Nmcli & Hosts)
Introduction to Docker
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
nouka inventry manager
SELF 2014: PBI v10: Application Management Made Easy
От sysV к systemd
Openvpn
Linux Kernel Parameter Tuning
Introduction to FreeNAS development by John Hixson
Glomosim
Ad

Viewers also liked (19)

DOCX
Sten
PPT
Totalitaarsete riikide kunst. elin lepik. 12b
PPTX
Muutused igapäevaelus varauusajal
PPTX
ODP
The Seven Wonders Of The Ancient Worls
PPT
Euroopa riigid
ODP
Uusaeg1 - varauusaeg konspekt
PDF
Musket age of warfare 2010
PDF
Industrial age1850 1900 spring 2011
PPTX
10 ptk sojandus uusajal
PPTX
Valgustus, Prantsuse revolutsioon, Napoleon gümnaasiumile
PPTX
The musket age
PPT
Euroopa riigid ja rahvad. Absolutism.
PPTX
Natsionaalsotsialistlik Saksamaa
PPTX
Inglise kodusõda 1642 1660
PPTX
Natsionaalsotsialistlik Saksamaa
PPTX
Talupoeg ja maaisand
PPTX
Vana-Egiptus
Sten
Totalitaarsete riikide kunst. elin lepik. 12b
Muutused igapäevaelus varauusajal
The Seven Wonders Of The Ancient Worls
Euroopa riigid
Uusaeg1 - varauusaeg konspekt
Musket age of warfare 2010
Industrial age1850 1900 spring 2011
10 ptk sojandus uusajal
Valgustus, Prantsuse revolutsioon, Napoleon gümnaasiumile
The musket age
Euroopa riigid ja rahvad. Absolutism.
Natsionaalsotsialistlik Saksamaa
Inglise kodusõda 1642 1660
Natsionaalsotsialistlik Saksamaa
Talupoeg ja maaisand
Vana-Egiptus
Ad

Similar to Building a moat bastion server (20)

PDF
Tested install-isp config3-ubuntu-16-04
PDF
Nginx2
PPTX
Kubernetes BateMetal Installation and Practice
PDF
Provisioning on Libvirt with Foreman
PPTX
kubernetes baremetal installation and practice
PDF
Genode Compositions
PPT
Razor, the Provisioning Toolbox - PuppetConf 2014
PPTX
Vagrant, Ansible, and OpenStack on your laptop
PDF
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
ODP
LSA2 - 02 Namespaces
PDF
Cobbler, Func and Puppet: Tools for Large Scale Environments
PDF
Cobbler, Func and Puppet: Tools for Large Scale Environments
DOCX
PDF
Implementation of DNS Anycast - a case study
PDF
Automação do físico ao NetSecDevOps
PDF
Linux Containers From Scratch
PDF
Instalando Cacti no CentOS 5
DOCX
Component pack 6006 install guide
PDF
Linux sever building
PDF
OSDC 2014: Jan-Piet Mens - Configuration Management with Ansible
Tested install-isp config3-ubuntu-16-04
Nginx2
Kubernetes BateMetal Installation and Practice
Provisioning on Libvirt with Foreman
kubernetes baremetal installation and practice
Genode Compositions
Razor, the Provisioning Toolbox - PuppetConf 2014
Vagrant, Ansible, and OpenStack on your laptop
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
LSA2 - 02 Namespaces
Cobbler, Func and Puppet: Tools for Large Scale Environments
Cobbler, Func and Puppet: Tools for Large Scale Environments
Implementation of DNS Anycast - a case study
Automação do físico ao NetSecDevOps
Linux Containers From Scratch
Instalando Cacti no CentOS 5
Component pack 6006 install guide
Linux sever building
OSDC 2014: Jan-Piet Mens - Configuration Management with Ansible

Building a moat bastion server

  • 3. What does it do? Provides a secure, single point of entry to your application servers
  • 4. Why do you care?
  • 5. What’s it look like? Service Requests SSH
  • 6. Bastion System Setup wget ruby* MySQL* curl postgresql* xorg* nginx net-snmp-libs jasper-libs Uninstall telnet everything! php* automake *X11 monit gcc DNS Name Server Mail Server ftp neon *devel* finger fetchmail net-snmp-libs
  • 7. Bastion System Setup install netcat
  • 8. Bastion System Setup update everything that remains! sudo yum upgrade
  • 9. Bastion SSH Config Change Port from 22 Port 2222 Disable password logins/auth PasswordAuthentication no Disable PAM UsePAM no
  • 10. Bastion IPTABLES DENY!!!!! /etc/sysconfig/iptables ... *filter :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT ACCEPT [237:32957] -A INPUT -i lo -j ACCEPT -A INPUT -m state --state ESTABLISHED -j ACCEPT -A INPUT -m state --state INVALID -j DROP -A INPUT -p icmp -j ACCEPT -A INPUT -p tcp -m tcp --dport 2222 -j ACCEPT COMMIT
  • 11. Bastion User Create a secure user group sudo /usr/sbin/groupadd moat Create a “keymaster” Generate and upload an SSH key
  • 12. Other Users Generate ssh-keys, use passphrases! sudo /usr/sbin/useradd -G moat -m new_user sudo mkdir -p /home/new_user/.ssh sudo mv ~/.new_user_ssh.pub /home/new_user/.ssh/authorized_keys sudo chmod -R 700 /home/new_user/.ssh sudo chown -R new_user:new_user /home/new_user/.ssh echo Any_r@nd0m_p@55w04D | sudo passwd new_user --stdin
  • 13. Protected Server Iptables ... *filter :INPUT DROP [0:0] :FORWARD DROP [0:0] ... -A INPUT -s <moat’s IP address> -p tcp -m tcp --dport 22 -j ACCEPT # HTTP and HTTPS -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT COMMIT
  • 14. SSH Proxy through moat to access remote machines Host app001 Hostname app-001.blackboxservers.com User app_user ProxyCommand ssh -q -p 2222 $MOAT_USER@moat-001.blackboxservers.com nc %h 22 To SSH, just export your name and go! $> export MOAT_USER=george $> ssh app001 george@app-001.blackboxservers.com's password: