SlideShare a Scribd company logo
Building a secure
bastion, or, 50
ways to kill your
server
Anna
Kennedy
@anna_ken_
Telenor Digital
What is a bastion (jumpbox) ?
bastion
server
server
server
Outside
world
What do we mean by secure?
How do we make a custom AMI?
Technical context
Ubuntu default packages
$ apt list --installed
Listing... Done
a11y-profile-manager-indicator/xenial,now 0.1.10-0ubuntu3 amd64 [installed]
accountsservice/xenial-updates,now 0.6.40-2ubuntu11.3 amd64 [installed]
acl/xenial,now 2.2.52-3 amd64 [installed]
acpi-support/xenial,now 0.142 amd64 [installed]
acpid/xenial,now 1:2.0.26-1ubuntu2 amd64 [installed]
activity-log-manager/xenial-updates,now 0.9.7-0ubuntu23.16.04.1 amd64 [installed]
adduser/xenial,xenial,now 3.113+nmu3ubuntu4 all [installed]
adium-theme-ubuntu/xenial-updates,xenial-updates,now 0.3.4-0ubuntu1.1 all [installed]
adwaita-icon-theme/xenial-updates,xenial-updates,now 3.18.0-2ubuntu3.1 all [installed]
aisleriot/xenial,now 1:3.18.2-1ubuntu1 amd64 [installed]
alien/xenial,xenial,now 8.95 all [installed,automatic]
alsa-base/xenial,xenial,now 1.0.25+dfsg-0ubuntu5 all [installed]
alsa-utils/xenial,now 1.1.0-0ubuntu5 amd64 [installed]
anacron/xenial,now 2.3-23 amd64 [installed]
$ dpkg-query -W
a11y-profile-manager-indicator 0.1.10-0ubuntu3
accountsservice 0.6.40-2ubuntu11.3
acl 2.2.52-3
acpi-support 0.142
acpid 1:2.0.26-1ubuntu2
activity-log-manager 0.9.7-0ubuntu23.16.04.1
adduser 3.113+nmu3ubuntu4
adium-theme-ubuntu 0.3.4-0ubuntu1.1
adwaita-icon-theme 3.18.0-2ubuntu3.1
aisleriot 1:3.18.2-1ubuntu1
alien 8.95
alsa-base 1.0.25+dfsg-0ubuntu5
alsa-utils 1.1.0-0ubuntu5
anacron 2.3-23
~2000 packages
Ubuntu default packages includes:
● ed
● ftp
● curl
● nano
● perl
● python
● rsync
● sed
● telnet
● wget
● vim-common
● adduser
● apt
● dpkg
?
● screen
● tmux
Just remove all optional / extra
packages
$ dpkg-query -Wf '${Package;-40}${Priority}n'
apt important
adduser required
at
standard
a11y-profile-manager-indicator optional
adium-theme-ubuntu extra
dpkg-query -Wf '${Package;-40}${Priority}n' |
awk '$2 ~ /optional|extra/ { print $1 }' |
xargs -I % sudo apt-get -y purge %
Turns out optional doesn’t mean
optional
‘Optional’ and ‘extra’ include:
● cloud-init
● grub
● linux-base
● openssh-server
● resolvconf
● ubuntu-server (meta-
Remove all packages that we don’t
want
ed
ftp
gawk
nano
rsync
screen
tmux
vim
wget
curl
net-tools
perl
python 2.7
python 3
tar
Remove all packages that we don’t
want, apart from the ones we can’t
Can remove:
ed
ftp
gawk
nano
rsync
screen
tmux
vim
wget
Can’t remove:
curl needed for consul restarts
net-tools needed for sshuttle
perl needed for ssh
python 2.7 needed for Ansible
python 3needed for AWS instance checks
tar needed for Ansible
Restricting user capabilities
Change all user shells to
/bin/nologin
Use rbash instead
of bash
Remove sudo from
all usersRestrict allowed commands in
authorized_keys
Restricting user capabilities
Change all user shells to
/bin/nologin
Restrict allowed commands in
authorized_keys
Use rbash instead
of bash
Remove sudo from
all users
sshuttle
sshuttle
sshuttle
Troubleshooting without sudo
Finally, a bootable, usable AMI
Install fail2ban
Use 2FA
Port knocking
Safe and secure
Thanks for
listening!
Anna
Kennedy
@anna_ken_
Telenor Digital

More Related Content

PDF
install mosquitto-auth-plug - cheat sheet -
DOCX
Install ,configure and manage opensips on kunbuntu
PDF
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
PDF
How to Connect MQTT Broker on ESP8266 WiFi
PDF
TechWiseTV Workshop: 5th Generation UCS
ODP
S4 sig-check-lpc-20130918
PDF
Network Device Development - Part 5: Firewall 104 ~ Packet Splitter
PDF
2015.10.05 Updated > Network Device Development - Part 2: Firewall 101
install mosquitto-auth-plug - cheat sheet -
Install ,configure and manage opensips on kunbuntu
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
How to Connect MQTT Broker on ESP8266 WiFi
TechWiseTV Workshop: 5th Generation UCS
S4 sig-check-lpc-20130918
Network Device Development - Part 5: Firewall 104 ~ Packet Splitter
2015.10.05 Updated > Network Device Development - Part 2: Firewall 101

What's hot (20)

PDF
DNF Failed To Open Cache
PDF
firmware hacking, slash the pineapple for fun (codebali 2015)
PPT
الفصل الخامس - الإدخال والإخراج - د. خالد بكرو Input and Output - Dr. Khaled ...
TXT
weddew
PDF
2015.10.05 Updated > Network Device Development - Part 1: Switch
TXT
Instrucciones
PDF
CIALUG: Encrypt all the things
DOCX
Install oracle service bus
PPT
Installing Loopback Adapter
PPT
Cisco pix firewall configuration for dcsl
PDF
Network Security
PPTX
444asus
PPTX
WebRTC for Managers!
PDF
Network Device Development - Part 4: Firewall 103 ~ Protocol Filter & Payload...
PDF
Installing and Using XBMC
ODP
Buildstrapping Aloofix
PPTX
Setup ephemeral password for TURN, Learn RTC in less than 200 Lines of code
PDF
Gns3 0.5 Tutorial
PDF
Joomla! security
DOCX
Fortinet SSL VPN access
DNF Failed To Open Cache
firmware hacking, slash the pineapple for fun (codebali 2015)
الفصل الخامس - الإدخال والإخراج - د. خالد بكرو Input and Output - Dr. Khaled ...
weddew
2015.10.05 Updated > Network Device Development - Part 1: Switch
Instrucciones
CIALUG: Encrypt all the things
Install oracle service bus
Installing Loopback Adapter
Cisco pix firewall configuration for dcsl
Network Security
444asus
WebRTC for Managers!
Network Device Development - Part 4: Firewall 103 ~ Protocol Filter & Payload...
Installing and Using XBMC
Buildstrapping Aloofix
Setup ephemeral password for TURN, Learn RTC in less than 200 Lines of code
Gns3 0.5 Tutorial
Joomla! security
Fortinet SSL VPN access
Ad

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
KodekX | Application Modernization Development
PDF
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Diabetes mellitus diagnosis method based random forest with bat algorithm
KodekX | Application Modernization Development
Encapsulation theory and applications.pdf
Ad

Building a secure bastion, or, 50 ways to kill your server

  • 1. Building a secure bastion, or, 50 ways to kill your server Anna Kennedy @anna_ken_ Telenor Digital
  • 2. What is a bastion (jumpbox) ? bastion server server server Outside world
  • 3. What do we mean by secure?
  • 4. How do we make a custom AMI?
  • 6. Ubuntu default packages $ apt list --installed Listing... Done a11y-profile-manager-indicator/xenial,now 0.1.10-0ubuntu3 amd64 [installed] accountsservice/xenial-updates,now 0.6.40-2ubuntu11.3 amd64 [installed] acl/xenial,now 2.2.52-3 amd64 [installed] acpi-support/xenial,now 0.142 amd64 [installed] acpid/xenial,now 1:2.0.26-1ubuntu2 amd64 [installed] activity-log-manager/xenial-updates,now 0.9.7-0ubuntu23.16.04.1 amd64 [installed] adduser/xenial,xenial,now 3.113+nmu3ubuntu4 all [installed] adium-theme-ubuntu/xenial-updates,xenial-updates,now 0.3.4-0ubuntu1.1 all [installed] adwaita-icon-theme/xenial-updates,xenial-updates,now 3.18.0-2ubuntu3.1 all [installed] aisleriot/xenial,now 1:3.18.2-1ubuntu1 amd64 [installed] alien/xenial,xenial,now 8.95 all [installed,automatic] alsa-base/xenial,xenial,now 1.0.25+dfsg-0ubuntu5 all [installed] alsa-utils/xenial,now 1.1.0-0ubuntu5 amd64 [installed] anacron/xenial,now 2.3-23 amd64 [installed] $ dpkg-query -W a11y-profile-manager-indicator 0.1.10-0ubuntu3 accountsservice 0.6.40-2ubuntu11.3 acl 2.2.52-3 acpi-support 0.142 acpid 1:2.0.26-1ubuntu2 activity-log-manager 0.9.7-0ubuntu23.16.04.1 adduser 3.113+nmu3ubuntu4 adium-theme-ubuntu 0.3.4-0ubuntu1.1 adwaita-icon-theme 3.18.0-2ubuntu3.1 aisleriot 1:3.18.2-1ubuntu1 alien 8.95 alsa-base 1.0.25+dfsg-0ubuntu5 alsa-utils 1.1.0-0ubuntu5 anacron 2.3-23 ~2000 packages
  • 7. Ubuntu default packages includes: ● ed ● ftp ● curl ● nano ● perl ● python ● rsync ● sed ● telnet ● wget ● vim-common ● adduser ● apt ● dpkg ? ● screen ● tmux
  • 8. Just remove all optional / extra packages $ dpkg-query -Wf '${Package;-40}${Priority}n' apt important adduser required at standard a11y-profile-manager-indicator optional adium-theme-ubuntu extra dpkg-query -Wf '${Package;-40}${Priority}n' | awk '$2 ~ /optional|extra/ { print $1 }' | xargs -I % sudo apt-get -y purge %
  • 9. Turns out optional doesn’t mean optional ‘Optional’ and ‘extra’ include: ● cloud-init ● grub ● linux-base ● openssh-server ● resolvconf ● ubuntu-server (meta-
  • 10. Remove all packages that we don’t want ed ftp gawk nano rsync screen tmux vim wget curl net-tools perl python 2.7 python 3 tar
  • 11. Remove all packages that we don’t want, apart from the ones we can’t Can remove: ed ftp gawk nano rsync screen tmux vim wget Can’t remove: curl needed for consul restarts net-tools needed for sshuttle perl needed for ssh python 2.7 needed for Ansible python 3needed for AWS instance checks tar needed for Ansible
  • 12. Restricting user capabilities Change all user shells to /bin/nologin Use rbash instead of bash Remove sudo from all usersRestrict allowed commands in authorized_keys
  • 13. Restricting user capabilities Change all user shells to /bin/nologin Restrict allowed commands in authorized_keys Use rbash instead of bash Remove sudo from all users sshuttle sshuttle sshuttle
  • 15. Finally, a bootable, usable AMI