Enhance OpenSSH for fun and security

Julien Pivotto
Julien PivottoOpen Source Consultant at Inuits
Enhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and Security
Julien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien Pivotto
LinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon Europe
October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015
Match User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluie
Julien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien Pivotto
• Sysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.eu
• FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004
• DevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believer
• @roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie on irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/github
inuits.eu
World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/80497449@N04/10012162166
Connected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devices
• MMMMMMMMMMMMMMMMMainframes
• SSSSSSSSSSSSSSSSServers
• VVVVVVVVVVVVVVVVVirtual machines
• CCCCCCCCCCCCCCCCContainers
• IIIIIIIIIIIIIIIIIoT
Entrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance Doors
• PPPPPPPPPPPPPPPPPhysical Access
• TTTTTTTTTTTTTTTTTelnet
• RRRRRRRRRRRRRRRRRSH
• SSSSSSSSSSSSSSSSSSH
• HHHHHHHHHHHHHHHHHTTPS
• ……………………………………………
SSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSH
• DDDDDDDDDDDDDDDDDozens of implementations
• OOOOOOOOOOOOOOOOOpenSSH
• DDDDDDDDDDDDDDDDDropbear (embedded)
• CCCCCCCCCCCCCCCCClosed-source
• ……………………………………………
SSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSH
• DDDDDDDDDDDDDDDDDozens of usecases
• SSSSSSSSSSSSSSSSShell access and TCP Tunelling
• CCCCCCCCCCCCCCCCCode (git)
• FFFFFFFFFFFFFFFFFile transfert (sftp)
• XXXXXXXXXXXXXXXXX terminal (x2go)
• AAAAAAAAAAAAAAAAAutomation (ansible)
• ……………………………………………
OpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSH
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/pennuja/5399766800
OpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSH
• DDDDDDDDDDDDDDDDDeveloped by the OpenBSD project
• RRRRRRRRRRRRRRRRReleased first in 1995
• SSSSSSSSSSSSSSSSServer/Client implementation
• IIIIIIIIIIIIIIIIIncluded in BSD, Linux, Cygwin, Mac OS X, …
• AAAAAAAAAAAAAAAAAvailable in many other platforms
Out of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scope
• FFFFFFFFFFFFFFFFFirewalling, OS, …
• BBBBBBBBBBBBBBBBBasic tips: RootLogin, Pubkeys, …
• CCCCCCCCCCCCCCCCCrypto/Encryption/Key Exchanges
https://stribika.github.io/2015/01/04/secure-
secure-shell.html
SecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecurity
Licensed under a Creative Commons Asstribution-ShareAlike 2.0 License
https://www.flickr.com/photos/111692634@N04/11406986014
Common senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon sense
• DDDDDDDDDDDDDDDDDo you need SSH? (immutable infra,
containers…)
• KKKKKKKKKKKKKKKKKISS
• CCCCCCCCCCCCCCCCChose what will get public IP and then
exposition.. hypervisors vs vms?
• PPPPPPPPPPPPPPPPPort 22 is not Evil
Server-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-sideServer-side
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/56001405@N06/6187271613
"Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config"
• /////////////////etc/ssh/sshd_config
• RRRRRRRRRRRRRRRRRestart of the service does not kill current
ssh sessions
Allow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rules
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/84388958@N03/7729300102
AllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsersAllowUsers
AllowUsers jenkins
AllowUsers jenkins nagios@172.31.29.5
AllowUsers jenkins nagios@172 .31.29.0/12
AllowUsers is exclusive
AllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroupsAllowGroups
AllowGroups staff jenkins
AllowGroups is exclusive
Allow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* ordering
• DDDDDDDDDDDDDDDDDenyUsers
• AAAAAAAAAAAAAAAAAllowUsers
• DDDDDDDDDDDDDDDDDenyGroups
• AAAAAAAAAAAAAAAAAllowGroups
MatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatch
• MMMMMMMMMMMMMMMMMatch + conditions
• rrrrrrrrrrrrrrrrreads until next Match or EOF
MatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatchMatch
AllowGroups staff
Match Address 172.31.16.8
AllowGroups staff jenkins
Trust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First Use
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/armandoh2o/7069748077
TOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFU
The authenticity of host 'example.com
(93.184.216.34)' can't be established.
ED25519 key fingerprint is SHA256:
eIvxpj9aMSS/+Ed7NQZ9er/
vyV17mabfiUxtgF2Q1X0.
Are you sure you want to continue
connecting (yes/no)?
Trust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first use
• WWWWWWWWWWWWWWWWWho checks the key on the server?
• WWWWWWWWWWWWWWWWWho says no?
• SSSSSSSSSSSSSSSSSecurity fatigue
Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)
• AAAAAAAAAAAAAAAAAutomation
• EEEEEEEEEEEEEEEEExport keys from hosts
• CCCCCCCCCCCCCCCCCollect them from hosts
• AAAAAAAAAAAAAAAAApply then to /etc/ssh/known_hosts
# saz/puppet−ssh − ASL 2.0
if $::sshrsakey {
@@sshkey { "${::fqdn}_rsa":
ensure => present,
host_aliases => $host_aliases,
type => rsa,
key => $::sshrsakey,
}
} else {
@@sshkey { "${::fqdn}_rsa":
ensure => absent,
}
}
Sshkey <<| |>>
Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)
• DDDDDDDDDDDDDDDDDNS
• EEEEEEEEEEEEEEEEExport keys in SSHFP DNS records
• CCCCCCCCCCCCCCCCCan be secured by DNSSEC
• hhhhhhhhhhhhhhhhhttps://github.com/jpmens/facts2sshfp
$ dig +short SSHFP example.com
1 1 F00A55CEA3B8E15528665A6781CA7C35190CF0
2 1 CC1F004DA60CF38E809FE58B10D0F22680D59D
ssh −o VerifyHostKeyDNS=yes example.com
The authenticity of host 'example.com
(93.184.216.34)' can't be established.
ED25519 key fingerprint is SHA256:
eIvxpj9aMSS/+Ed7NQZ9er/
vyV17mabfiUxtgF2Q1X0.
Matching host key fingerprint found in DNS
Are you sure you want to continue
connecting (yes/no)?
Authorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keys
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/brenda-starr/4498078166
ssh−rsa AAsafgrewgBzhfadgthgfpoDtGlUBIYhzf user@desktop
• OOOOOOOOOOOOOOOOOne key, one user
• AAAAAAAAAAAAAAAAAlways with a password
• DDDDDDDDDDDDDDDDDistribute them in an automated way
from="172.21.32.4" ssh−rsa AAspoDtGlUBIYhzf ansible
no−port−forwarding ,no−x11−forwarding ,no−agent−forwarding
ssh−rsa AAspDjeFJwFRf jenkins
ssh_authorized_key {
'jenkins ':
type => 'ssh−rsa',
key => 'AAAAKZ6TwZl3ikhY42clyY/De7J ',
user => 'jenkins ',
}
ssh_authorized_key {
'jenkins ':
type => 'ssh−rsa',
key => 'AAAAKZ6TwZl3ikhY42clyY/De7J ',
user => 'jenkins ',
options => 'from="192.168.10.1"'
}
Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!
user {
'jenkins ':
purge_ssh_keys => true ,
}
AuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommandAuthorizedKeysCommand
• SSSSSSSSSSSSSSSSScript that takes username as arguments
and returns authorized_keys
• EEEEEEEEEEEEEEEEExemple reference: openssh-ldap RPM
Client SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient Side
Licensed under a Creative Commons Zero License
@roidelapluie
Client configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configuration
• $$$$$$$$$$$$$$$$$HOME/.ssh/config
• /////////////////etc/ssh/ssh_config
Host web1
Hostname web1.example.com
User roidelapluie
SSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH Hops
Licensed under a Creative Commons Attribution-ShareAlike 2.0 License
https://www.flickr.com/photos/sarahrosenau/269786597
Host web1
Proxycommand ssh proxy nc %h %p
Host proxy
Proxycommand ssh out nc %h %p
SSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH Hops
• AAAAAAAAAAAAAAAAAcces restricted areas
• KKKKKKKKKKKKKKKKKeeps your private keys in your machine
• NNNNNNNNNNNNNNNNNo need for agent forwarding
SocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSockets
Licensed under a Creative Commons Attribution-ShareAlike 2.0 License
https://www.flickr.com/photos/restlessglobetrotter/2661016046
Host git.example.com
ControlMaster auto
ControlPath /tmp/ssh−%r@%h:%p
ControlPersist 5
SSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH Sockets
• SSSSSSSSSSSSSSSSSpeed up reconnection time
• DDDDDDDDDDDDDDDDDo not renegotiate each time
• UUUUUUUUUUUUUUUUUseful for git
Stopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSH
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/horiavarlan/4747872021
Send to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to background
<enter > ~ &
PausePausePausePausePausePausePausePausePausePausePausePausePausePausePausePausePause
<enter > ~ <ctrl+z>
Kill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the session
<enter > ~ .
TunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnels
Licensed under a Creative Commons Attribution-ShareAlike 2.0 License
https://www.flickr.com/photos/hanuska/5174842932
TunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnels
• TTTTTTTTTTTTTTTTTCP Tunnels
• SSSSSSSSSSSSSSSSSOCKS proxy
TunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnels
• LLLLLLLLLLLLLLLLLocal TCP Port Forwarding: give remote
acces to local port
• RRRRRRRRRRRRRRRRRemote TCP Port Forwarding: get access to
remote ports
Local TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port Forwarding
Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library
and the Tango Icons project
Local TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port Forwarding
Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library
and the Tango Icons project
Local TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port Forwarding
Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library
and the Tango Icons project
Local TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel example
• UUUUUUUUUUUUUUUUUser A is natted behind a firewall
• HHHHHHHHHHHHHHHHHe wants to give User B access to local SSH
daemon
userA@hostA > ssh −NR 22222:localhost:22 userA@hostB
userB@hostB > ssh −p 22222 localhost
-N is for No Shell
Remote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port Forwarding
Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library
and the Tango Icons project
Remote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port Forwarding
Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library
and the Tango Icons project
Remote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding example
• UUUUUUUUUUUUUUUUUser A is behind a firewall that blocks VNC
port
• HHHHHHHHHHHHHHHHHe wants to access User B local VNC
daemon
userA@hostA > ssh −NL 5900:localhost:5900 userA@hostB
userA@hostA > vncviewer localhost
SOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS Proxy
• """""""""""""""""Dynamic" port forwarding
• EEEEEEEEEEEEEEEEEnable UDP, TCP, …
• CCCCCCCCCCCCCCCCCreates a SOCKS5 proxy
userA@hostA > ssh −ND 9500 userA@hostB
userA@hostA > proxychains wget http://example.com
ToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsTools
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/86639298@N02/8559728371
ssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agent
• SSSSSSSSSSSSSSSSStores your private key in memory
• eeeeeeeeeeeeeeeeeval $(ssh-agent)
• ssssssssssssssssssh-add; ssh-add -t 1h foo.key
• ssssssssssssssssssh-add -x (lock)
• ssssssssssssssssssh-add -X (unlock)
• PPPPPPPPPPPPPPPPPart of OpenSSH
screenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreen
• KKKKKKKKKKKKKKKKKeep session accross ssh connection
• HHHHHHHHHHHHHHHHHave multiple shell `windows'
• RRRRRRRRRRRRRRRRRun long command and keep them running
• ssssssssssssssssscreen (launch new session)
• CCCCCCCCCCCCCCCCCtrl+a d (detach)
• ssssssssssssssssscreen -dx (detach and reattach)
• ssssssssssssssssssh host -t screen -dx
• AAAAAAAAAAAAAAAAAlternative: tmux
reptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyr
• AAAAAAAAAAAAAAAAAttach a long running process to the current
terminal
• IIIIIIIIIIIIIIIIIdea: launch a screen and rattach another
process inside
• UUUUUUUUUUUUUUUUUseful when you forgot to launch your
screen before
• rrrrrrrrrrrrrrrrreptyr -p PID
vimvimvimvimvimvimvimvimvimvimvimvimvimvimvimvimvim
• EEEEEEEEEEEEEEEEEdit files remotely with scp
• vvvvvvvvvvvvvvvvvim scp://web//etc/hosts
ConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusion
Licensed under a Creative Commons Attribution 2.0 License
https://www.flickr.com/photos/freddyfromutah/4424199420
ConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusion
• SSSSSSSSSSSSSSSSSSH is still part of modern infrastructures
• IIIIIIIIIIIIIIIIIt should be part of what you
automate/control
• LLLLLLLLLLLLLLLLLots of other projects rely on it
• YYYYYYYYYYYYYYYYYou can harden it in a lot of ways
• TTTTTTTTTTTTTTTTThere is a lot of things to discover!
HomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomework
• SSSSSSSSSSSSSSSSSSH certificate authority
• cccccccccccccccccommand= permitopen=
• MMMMMMMMMMMMMMMMMatch blocks
• sssssssssssssssssshfs
• ……………………………………………
Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?
ContactContactContactContactContactContactContactContactContactContactContactContactContactContactContactContactContact
Julien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien Pivotto
julien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eu
@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie
inuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuits
https://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.eu
info@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.eu
+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636
1 of 72

Recommended

Getting the maximum out of systemd by
Getting the maximum out of systemdGetting the maximum out of systemd
Getting the maximum out of systemdJulien Pivotto
8.6K views75 slides
systemd and configuration management by
systemd and configuration managementsystemd and configuration management
systemd and configuration managementJulien Pivotto
2.9K views56 slides
RPM experiments by
RPM experimentsRPM experiments
RPM experimentsJulien Pivotto
1.6K views42 slides
Puppet and Software Delivery by
Puppet and Software DeliveryPuppet and Software Delivery
Puppet and Software DeliveryJulien Pivotto
2.2K views50 slides
Monitoring at Cloud Scale by
Monitoring at Cloud ScaleMonitoring at Cloud Scale
Monitoring at Cloud ScaleJulien Pivotto
8.5K views47 slides
Building and Deploying MediaSalsa, a drupal-based DAM as a Service by
Building and Deploying MediaSalsa, a drupal-based DAM as a ServiceBuilding and Deploying MediaSalsa, a drupal-based DAM as a Service
Building and Deploying MediaSalsa, a drupal-based DAM as a ServiceJulien Pivotto
4.8K views32 slides

More Related Content

What's hot

Coworking with git by
Coworking with gitCoworking with git
Coworking with gitJulien Pivotto
2.7K views58 slides
Postgresql 9.0 HA at RMLL 2012 by
Postgresql 9.0 HA at RMLL 2012Postgresql 9.0 HA at RMLL 2012
Postgresql 9.0 HA at RMLL 2012Julien Pivotto
4K views119 slides
Diving Into Puppet Providers Development: The Puppet-Corosync Module by
Diving Into Puppet Providers Development: The Puppet-Corosync ModuleDiving Into Puppet Providers Development: The Puppet-Corosync Module
Diving Into Puppet Providers Development: The Puppet-Corosync ModuleJulien Pivotto
2.1K views82 slides
Deployment and Continous Integration of a Zope/Plone application by
Deployment and Continous Integration of a Zope/Plone applicationDeployment and Continous Integration of a Zope/Plone application
Deployment and Continous Integration of a Zope/Plone applicationJulien Pivotto
4.2K views41 slides
Testing your puppet code by
Testing your puppet codeTesting your puppet code
Testing your puppet codeJulien Pivotto
5.3K views34 slides
Making Py Pi Sux Less Key by
Making Py Pi Sux Less KeyMaking Py Pi Sux Less Key
Making Py Pi Sux Less KeyAndreas Jung
1.8K views9 slides

What's hot(20)

Diving Into Puppet Providers Development: The Puppet-Corosync Module by Julien Pivotto
Diving Into Puppet Providers Development: The Puppet-Corosync ModuleDiving Into Puppet Providers Development: The Puppet-Corosync Module
Diving Into Puppet Providers Development: The Puppet-Corosync Module
Julien Pivotto2.1K views
Deployment and Continous Integration of a Zope/Plone application by Julien Pivotto
Deployment and Continous Integration of a Zope/Plone applicationDeployment and Continous Integration of a Zope/Plone application
Deployment and Continous Integration of a Zope/Plone application
Julien Pivotto4.2K views
Making Py Pi Sux Less Key by Andreas Jung
Making Py Pi Sux Less KeyMaking Py Pi Sux Less Key
Making Py Pi Sux Less Key
Andreas Jung1.8K views
Continous Delivery of your Infrastructure by Kris Buytaert
Continous Delivery of your InfrastructureContinous Delivery of your Infrastructure
Continous Delivery of your Infrastructure
Kris Buytaert857 views
The Future of System Administration by Kris Buytaert
The Future of System AdministrationThe Future of System Administration
The Future of System Administration
Kris Buytaert15.1K views
11 Tools for your Open Source devops stack by Kris Buytaert
11 Tools for your Open Source devops stack 11 Tools for your Open Source devops stack
11 Tools for your Open Source devops stack
Kris Buytaert13.5K views
How I hack on puppet modules by Kris Buytaert
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modules
Kris Buytaert8.7K views
Life Cycle of Metrics, Alerting, and Performance Monitoring in Microservices by Sean Chittenden
Life Cycle of Metrics, Alerting, and Performance Monitoring in MicroservicesLife Cycle of Metrics, Alerting, and Performance Monitoring in Microservices
Life Cycle of Metrics, Alerting, and Performance Monitoring in Microservices
Sean Chittenden737 views
Closing the gap between Distros(devs) and their Users(ops) by Kris Buytaert
Closing the gap between Distros(devs) and their Users(ops)Closing the gap between Distros(devs) and their Users(ops)
Closing the gap between Distros(devs) and their Users(ops)
Kris Buytaert15.9K views
Open Source Monitoring in 2015 by Kris Buytaert
Open Source Monitoring in 2015Open Source Monitoring in 2015
Open Source Monitoring in 2015
Kris Buytaert2.3K views
On the Importance of Infrastructure as Code by Kris Buytaert
On the Importance of Infrastructure as CodeOn the Importance of Infrastructure as Code
On the Importance of Infrastructure as Code
Kris Buytaert1.8K views
ContainerCon - Test Driven Infrastructure by Yury Tsarev
ContainerCon - Test Driven InfrastructureContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven Infrastructure
Yury Tsarev2.6K views
Automating MySQL operations with Puppet by Kris Buytaert
Automating MySQL operations with PuppetAutomating MySQL operations with Puppet
Automating MySQL operations with Puppet
Kris Buytaert1.8K views
From MonitoringSucks to Monitoring Love , 2016 Edition by Kris Buytaert
From MonitoringSucks to Monitoring Love , 2016 EditionFrom MonitoringSucks to Monitoring Love , 2016 Edition
From MonitoringSucks to Monitoring Love , 2016 Edition
Kris Buytaert29.4K views
7 tools for your devops stack by Kris Buytaert
7 tools for your devops stack7 tools for your devops stack
7 tools for your devops stack
Kris Buytaert35.9K views
Devops is a Security Requirement by Kris Buytaert
Devops is a Security RequirementDevops is a Security Requirement
Devops is a Security Requirement
Kris Buytaert699 views

Similar to Enhance OpenSSH for fun and security

CentOS Config Management SIG by
CentOS Config Management SIGCentOS Config Management SIG
CentOS Config Management SIGJulien Pivotto
2.4K views20 slides
OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi... by
OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi...OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi...
OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi...NETWAYS
143 views91 slides
Devops -- LKFR14 by
Devops -- LKFR14Devops -- LKFR14
Devops -- LKFR14Lean Kanban France
103 views96 slides
Managing a R&D Lab with Foreman by
Managing a R&D Lab with ForemanManaging a R&D Lab with Foreman
Managing a R&D Lab with ForemanJulien Pivotto
1K views91 slides
Managing a R&D Lab with Foreman by
Managing a R&D Lab with ForemanManaging a R&D Lab with Foreman
Managing a R&D Lab with ForemanJulien Pivotto
1.6K views91 slides
Dev secops opsec, devsec, devops ? by
Dev secops opsec, devsec, devops ?Dev secops opsec, devsec, devops ?
Dev secops opsec, devsec, devops ?Kris Buytaert
17.4K views57 slides

Similar to Enhance OpenSSH for fun and security(20)

CentOS Config Management SIG by Julien Pivotto
CentOS Config Management SIGCentOS Config Management SIG
CentOS Config Management SIG
Julien Pivotto2.4K views
OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi... by NETWAYS
OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi...OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi...
OSDC 2016 - Automating a R&D lab with Foreman: What can be hard? by Julien Pi...
NETWAYS143 views
Managing a R&D Lab with Foreman by Julien Pivotto
Managing a R&D Lab with ForemanManaging a R&D Lab with Foreman
Managing a R&D Lab with Foreman
Julien Pivotto1K views
Managing a R&D Lab with Foreman by Julien Pivotto
Managing a R&D Lab with ForemanManaging a R&D Lab with Foreman
Managing a R&D Lab with Foreman
Julien Pivotto1.6K views
Dev secops opsec, devsec, devops ? by Kris Buytaert
Dev secops opsec, devsec, devops ?Dev secops opsec, devsec, devops ?
Dev secops opsec, devsec, devops ?
Kris Buytaert17.4K views
An introduction to the Pulp project by Julien Pivotto
An introduction to the Pulp projectAn introduction to the Pulp project
An introduction to the Pulp project
Julien Pivotto9.6K views
Run stuff, Deploy Stuff, Jax London 2017 Edition by Kris Buytaert
Run stuff, Deploy Stuff, Jax London 2017 EditionRun stuff, Deploy Stuff, Jax London 2017 Edition
Run stuff, Deploy Stuff, Jax London 2017 Edition
Kris Buytaert2.2K views
Using Liferay Portal with LDAP and Single sign-on by Firelay
Using Liferay Portal with LDAP and Single sign-onUsing Liferay Portal with LDAP and Single sign-on
Using Liferay Portal with LDAP and Single sign-on
Firelay7.9K views
Another 7 tools for your #devops stack by Kris Buytaert
Another 7 tools for your #devops stackAnother 7 tools for your #devops stack
Another 7 tools for your #devops stack
Kris Buytaert1.6K views
OSDC 2016 - Another 7 Tools for your #devops Stack by Kris Buytaert by NETWAYS
OSDC 2016 - Another 7 Tools for your #devops Stack by Kris BuytaertOSDC 2016 - Another 7 Tools for your #devops Stack by Kris Buytaert
OSDC 2016 - Another 7 Tools for your #devops Stack by Kris Buytaert
NETWAYS81 views
From Config Management Sucks to #cfgmgmtlove by Kris Buytaert
From Config Management Sucks to #cfgmgmtlove From Config Management Sucks to #cfgmgmtlove
From Config Management Sucks to #cfgmgmtlove
Kris Buytaert2K views
Town Hall - Business Implications of Open Source OSGi Implementations - BJ Ha... by mfrancis
Town Hall - Business Implications of Open Source OSGi Implementations - BJ Ha...Town Hall - Business Implications of Open Source OSGi Implementations - BJ Ha...
Town Hall - Business Implications of Open Source OSGi Implementations - BJ Ha...
mfrancis280 views
"The Sorry State of SSL" Hynek Schlawack, PyConRu 2014 by it-people
"The Sorry State of SSL" Hynek Schlawack, PyConRu 2014"The Sorry State of SSL" Hynek Schlawack, PyConRu 2014
"The Sorry State of SSL" Hynek Schlawack, PyConRu 2014
it-people1.3K views

More from Julien Pivotto

The O11y Toolkit by
The O11y ToolkitThe O11y Toolkit
The O11y ToolkitJulien Pivotto
37 views24 slides
What's New in Prometheus and Its Ecosystem by
What's New in Prometheus and Its EcosystemWhat's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its EcosystemJulien Pivotto
12 views42 slides
Prometheus: What is is, what is new, what is coming by
Prometheus: What is is, what is new, what is comingPrometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is comingJulien Pivotto
42 views27 slides
What's new in Prometheus? by
What's new in Prometheus?What's new in Prometheus?
What's new in Prometheus?Julien Pivotto
15 views10 slides
Introduction to Grafana Loki by
Introduction to Grafana LokiIntroduction to Grafana Loki
Introduction to Grafana LokiJulien Pivotto
194 views11 slides
Why you should revisit mgmt by
Why you should revisit mgmtWhy you should revisit mgmt
Why you should revisit mgmtJulien Pivotto
10 views46 slides

More from Julien Pivotto(20)

What's New in Prometheus and Its Ecosystem by Julien Pivotto
What's New in Prometheus and Its EcosystemWhat's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its Ecosystem
Julien Pivotto12 views
Prometheus: What is is, what is new, what is coming by Julien Pivotto
Prometheus: What is is, what is new, what is comingPrometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is coming
Julien Pivotto42 views
Introduction to Grafana Loki by Julien Pivotto
Introduction to Grafana LokiIntroduction to Grafana Loki
Introduction to Grafana Loki
Julien Pivotto194 views
Observing the HashiCorp Ecosystem From Prometheus by Julien Pivotto
Observing the HashiCorp Ecosystem From PrometheusObserving the HashiCorp Ecosystem From Prometheus
Observing the HashiCorp Ecosystem From Prometheus
Julien Pivotto37 views
Monitoring in a fast-changing world with Prometheus by Julien Pivotto
Monitoring in a fast-changing world with PrometheusMonitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with Prometheus
Julien Pivotto33 views
5 tips for Prometheus Service Discovery by Julien Pivotto
5 tips for Prometheus Service Discovery5 tips for Prometheus Service Discovery
5 tips for Prometheus Service Discovery
Julien Pivotto38 views
Prometheus and TLS - an Introduction by Julien Pivotto
Prometheus and TLS - an IntroductionPrometheus and TLS - an Introduction
Prometheus and TLS - an Introduction
Julien Pivotto15 views
HAProxy as Egress Controller by Julien Pivotto
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress Controller
Julien Pivotto2.9K views
Improved alerting with Prometheus and Alertmanager by Julien Pivotto
Improved alerting with Prometheus and AlertmanagerImproved alerting with Prometheus and Alertmanager
Improved alerting with Prometheus and Alertmanager
Julien Pivotto4.5K views
SIngle Sign On with Keycloak by Julien Pivotto
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with Keycloak
Julien Pivotto10K views
Monitoring as an entry point for collaboration by Julien Pivotto
Monitoring as an entry point for collaborationMonitoring as an entry point for collaboration
Monitoring as an entry point for collaboration
Julien Pivotto1.3K views
Monitor your CentOS stack with Prometheus by Julien Pivotto
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
Julien Pivotto712 views
Monitor your CentOS stack with Prometheus by Julien Pivotto
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
Julien Pivotto704 views

Recently uploaded

PharoJS - Zürich Smalltalk Group Meetup November 2023 by
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
141 views17 slides
Network Source of Truth and Infrastructure as Code revisited by
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisitedNetwork Automation Forum
42 views45 slides
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
74 views18 slides
DRBD Deep Dive - Philipp Reisner - LINBIT by
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBITShapeBlue
62 views21 slides
MVP and prioritization.pdf by
MVP and prioritization.pdfMVP and prioritization.pdf
MVP and prioritization.pdfrahuldharwal141
38 views8 slides
"Surviving highload with Node.js", Andrii Shumada by
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada Fwdays
40 views29 slides

Recently uploaded(20)

PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi141 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue74 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue62 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays40 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue88 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue102 views
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn28 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue65 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue96 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue56 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman40 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue131 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue46 views

Enhance OpenSSH for fun and security

  • 1. Enhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and SecurityEnhance OpenSSH for Fun and Security Julien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien Pivotto LinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon EuropeLinuxCon Europe October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015October 5, 2015
  • 2. Match User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluieMatch User roidelapluie Julien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien Pivotto • Sysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.euSysadmin at inuits.eu • FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004FLOSS user since 2004 • DevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believerDevOps believer • @roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie on irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/githubon irc/twitter/github
  • 4. World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015World, 2015 Licensed under a Creative Commons Attribution 2.0 License https://www.flickr.com/photos/80497449@N04/10012162166
  • 5. Connected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devicesConnected devices • MMMMMMMMMMMMMMMMMainframes • SSSSSSSSSSSSSSSSServers • VVVVVVVVVVVVVVVVVirtual machines • CCCCCCCCCCCCCCCCContainers • IIIIIIIIIIIIIIIIIoT
  • 6. Entrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance DoorsEntrance Doors • PPPPPPPPPPPPPPPPPhysical Access • TTTTTTTTTTTTTTTTTelnet • RRRRRRRRRRRRRRRRRSH • SSSSSSSSSSSSSSSSSSH • HHHHHHHHHHHHHHHHHTTPS • ……………………………………………
  • 7. SSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSH • DDDDDDDDDDDDDDDDDozens of implementations • OOOOOOOOOOOOOOOOOpenSSH • DDDDDDDDDDDDDDDDDropbear (embedded) • CCCCCCCCCCCCCCCCClosed-source • ……………………………………………
  • 8. SSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSHSSH • DDDDDDDDDDDDDDDDDozens of usecases • SSSSSSSSSSSSSSSSShell access and TCP Tunelling • CCCCCCCCCCCCCCCCCode (git) • FFFFFFFFFFFFFFFFFile transfert (sftp) • XXXXXXXXXXXXXXXXX terminal (x2go) • AAAAAAAAAAAAAAAAAutomation (ansible) • ……………………………………………
  • 9. OpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSH Licensed under a Creative Commons Attribution 2.0 License https://www.flickr.com/photos/pennuja/5399766800
  • 10. OpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSHOpenSSH • DDDDDDDDDDDDDDDDDeveloped by the OpenBSD project • RRRRRRRRRRRRRRRRReleased first in 1995 • SSSSSSSSSSSSSSSSServer/Client implementation • IIIIIIIIIIIIIIIIIncluded in BSD, Linux, Cygwin, Mac OS X, … • AAAAAAAAAAAAAAAAAvailable in many other platforms
  • 11. Out of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scopeOut of scope • FFFFFFFFFFFFFFFFFirewalling, OS, … • BBBBBBBBBBBBBBBBBasic tips: RootLogin, Pubkeys, … • CCCCCCCCCCCCCCCCCrypto/Encryption/Key Exchanges https://stribika.github.io/2015/01/04/secure- secure-shell.html
  • 12. SecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecuritySecurity Licensed under a Creative Commons Asstribution-ShareAlike 2.0 License https://www.flickr.com/photos/111692634@N04/11406986014
  • 13. Common senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon senseCommon sense • DDDDDDDDDDDDDDDDDo you need SSH? (immutable infra, containers…) • KKKKKKKKKKKKKKKKKISS • CCCCCCCCCCCCCCCCChose what will get public IP and then exposition.. hypervisors vs vms? • PPPPPPPPPPPPPPPPPort 22 is not Evil
  • 15. "Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config""Server config" • /////////////////etc/ssh/sshd_config • RRRRRRRRRRRRRRRRRestart of the service does not kill current ssh sessions
  • 16. Allow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rulesAllow/Deny rules Licensed under a Creative Commons Attribution 2.0 License https://www.flickr.com/photos/84388958@N03/7729300102
  • 19. Allow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* orderingAllow* ordering • DDDDDDDDDDDDDDDDDenyUsers • AAAAAAAAAAAAAAAAAllowUsers • DDDDDDDDDDDDDDDDDenyGroups • AAAAAAAAAAAAAAAAAllowGroups
  • 22. Trust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First UseTrust On First Use Licensed under a Creative Commons Attribution 2.0 License https://www.flickr.com/photos/armandoh2o/7069748077
  • 23. TOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFUTOFU The authenticity of host 'example.com (93.184.216.34)' can't be established. ED25519 key fingerprint is SHA256: eIvxpj9aMSS/+Ed7NQZ9er/ vyV17mabfiUxtgF2Q1X0. Are you sure you want to continue connecting (yes/no)?
  • 24. Trust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first useTrust on first use • WWWWWWWWWWWWWWWWWho checks the key on the server? • WWWWWWWWWWWWWWWWWho says no? • SSSSSSSSSSSSSSSSSecurity fatigue
  • 25. Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2)Alternative to TOFU (1/2) • AAAAAAAAAAAAAAAAAutomation • EEEEEEEEEEEEEEEEExport keys from hosts • CCCCCCCCCCCCCCCCCollect them from hosts • AAAAAAAAAAAAAAAAApply then to /etc/ssh/known_hosts
  • 26. # saz/puppet−ssh − ASL 2.0 if $::sshrsakey { @@sshkey { "${::fqdn}_rsa": ensure => present, host_aliases => $host_aliases, type => rsa, key => $::sshrsakey, } } else { @@sshkey { "${::fqdn}_rsa": ensure => absent, } }
  • 28. Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2)Alternative to TOFU (2/2) • DDDDDDDDDDDDDDDDDNS • EEEEEEEEEEEEEEEEExport keys in SSHFP DNS records • CCCCCCCCCCCCCCCCCan be secured by DNSSEC • hhhhhhhhhhhhhhhhhttps://github.com/jpmens/facts2sshfp
  • 29. $ dig +short SSHFP example.com 1 1 F00A55CEA3B8E15528665A6781CA7C35190CF0 2 1 CC1F004DA60CF38E809FE58B10D0F22680D59D
  • 31. The authenticity of host 'example.com (93.184.216.34)' can't be established. ED25519 key fingerprint is SHA256: eIvxpj9aMSS/+Ed7NQZ9er/ vyV17mabfiUxtgF2Q1X0. Matching host key fingerprint found in DNS Are you sure you want to continue connecting (yes/no)?
  • 32. Authorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keysAuthorized keys Licensed under a Creative Commons Attribution 2.0 License https://www.flickr.com/photos/brenda-starr/4498078166
  • 33. ssh−rsa AAsafgrewgBzhfadgthgfpoDtGlUBIYhzf user@desktop • OOOOOOOOOOOOOOOOOne key, one user • AAAAAAAAAAAAAAAAAlways with a password • DDDDDDDDDDDDDDDDDistribute them in an automated way
  • 34. from="172.21.32.4" ssh−rsa AAspoDtGlUBIYhzf ansible no−port−forwarding ,no−x11−forwarding ,no−agent−forwarding ssh−rsa AAspDjeFJwFRf jenkins
  • 35. ssh_authorized_key { 'jenkins ': type => 'ssh−rsa', key => 'AAAAKZ6TwZl3ikhY42clyY/De7J ', user => 'jenkins ', }
  • 36. ssh_authorized_key { 'jenkins ': type => 'ssh−rsa', key => 'AAAAKZ6TwZl3ikhY42clyY/De7J ', user => 'jenkins ', options => 'from="192.168.10.1"' }
  • 37. Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys!Purge undefined keys! user { 'jenkins ': purge_ssh_keys => true , }
  • 39. Client SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient SideClient Side Licensed under a Creative Commons Zero License @roidelapluie
  • 40. Client configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configurationClient configuration • $$$$$$$$$$$$$$$$$HOME/.ssh/config • /////////////////etc/ssh/ssh_config
  • 42. SSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH Hops Licensed under a Creative Commons Attribution-ShareAlike 2.0 License https://www.flickr.com/photos/sarahrosenau/269786597
  • 43. Host web1 Proxycommand ssh proxy nc %h %p Host proxy Proxycommand ssh out nc %h %p
  • 44. SSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH HopsSSH Hops • AAAAAAAAAAAAAAAAAcces restricted areas • KKKKKKKKKKKKKKKKKeeps your private keys in your machine • NNNNNNNNNNNNNNNNNo need for agent forwarding
  • 45. SocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSocketsSockets Licensed under a Creative Commons Attribution-ShareAlike 2.0 License https://www.flickr.com/photos/restlessglobetrotter/2661016046
  • 46. Host git.example.com ControlMaster auto ControlPath /tmp/ssh−%r@%h:%p ControlPersist 5
  • 47. SSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH SocketsSSH Sockets • SSSSSSSSSSSSSSSSSpeed up reconnection time • DDDDDDDDDDDDDDDDDo not renegotiate each time • UUUUUUUUUUUUUUUUUseful for git
  • 48. Stopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSHStopping OpenSSH Licensed under a Creative Commons Attribution 2.0 License https://www.flickr.com/photos/horiavarlan/4747872021
  • 49. Send to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to backgroundSend to background <enter > ~ &
  • 51. Kill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the sessionKill the session <enter > ~ .
  • 52. TunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnels Licensed under a Creative Commons Attribution-ShareAlike 2.0 License https://www.flickr.com/photos/hanuska/5174842932
  • 54. TunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnelsTunnels • LLLLLLLLLLLLLLLLLocal TCP Port Forwarding: give remote acces to local port • RRRRRRRRRRRRRRRRRemote TCP Port Forwarding: get access to remote ports
  • 55. Local TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port Forwarding Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library and the Tango Icons project
  • 56. Local TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port Forwarding Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library and the Tango Icons project
  • 57. Local TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port ForwardingLocal TCP Port Forwarding Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library and the Tango Icons project
  • 58. Local TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel exampleLocal TCP Tunnel example • UUUUUUUUUUUUUUUUUser A is natted behind a firewall • HHHHHHHHHHHHHHHHHe wants to give User B access to local SSH daemon userA@hostA > ssh −NR 22222:localhost:22 userA@hostB userB@hostB > ssh −p 22222 localhost -N is for No Shell
  • 59. Remote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port Forwarding Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library and the Tango Icons project
  • 60. Remote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port ForwardingRemote TCP Port Forwarding Icons from http://www.opensecurityarchitecture.org/cms/library/icon-library and the Tango Icons project
  • 61. Remote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding exampleRemote Port Forwarding example • UUUUUUUUUUUUUUUUUser A is behind a firewall that blocks VNC port • HHHHHHHHHHHHHHHHHe wants to access User B local VNC daemon userA@hostA > ssh −NL 5900:localhost:5900 userA@hostB userA@hostA > vncviewer localhost
  • 62. SOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS ProxySOCKS Proxy • """""""""""""""""Dynamic" port forwarding • EEEEEEEEEEEEEEEEEnable UDP, TCP, … • CCCCCCCCCCCCCCCCCreates a SOCKS5 proxy userA@hostA > ssh −ND 9500 userA@hostB userA@hostA > proxychains wget http://example.com
  • 63. ToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsToolsTools Licensed under a Creative Commons Attribution 2.0 License https://www.flickr.com/photos/86639298@N02/8559728371
  • 64. ssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agentssh-agent • SSSSSSSSSSSSSSSSStores your private key in memory • eeeeeeeeeeeeeeeeeval $(ssh-agent) • ssssssssssssssssssh-add; ssh-add -t 1h foo.key • ssssssssssssssssssh-add -x (lock) • ssssssssssssssssssh-add -X (unlock) • PPPPPPPPPPPPPPPPPart of OpenSSH
  • 65. screenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreenscreen • KKKKKKKKKKKKKKKKKeep session accross ssh connection • HHHHHHHHHHHHHHHHHave multiple shell `windows' • RRRRRRRRRRRRRRRRRun long command and keep them running • ssssssssssssssssscreen (launch new session) • CCCCCCCCCCCCCCCCCtrl+a d (detach) • ssssssssssssssssscreen -dx (detach and reattach) • ssssssssssssssssssh host -t screen -dx • AAAAAAAAAAAAAAAAAlternative: tmux
  • 66. reptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyrreptyr • AAAAAAAAAAAAAAAAAttach a long running process to the current terminal • IIIIIIIIIIIIIIIIIdea: launch a screen and rattach another process inside • UUUUUUUUUUUUUUUUUseful when you forgot to launch your screen before • rrrrrrrrrrrrrrrrreptyr -p PID
  • 67. vimvimvimvimvimvimvimvimvimvimvimvimvimvimvimvimvim • EEEEEEEEEEEEEEEEEdit files remotely with scp • vvvvvvvvvvvvvvvvvim scp://web//etc/hosts
  • 69. ConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusionConclusion • SSSSSSSSSSSSSSSSSSH is still part of modern infrastructures • IIIIIIIIIIIIIIIIIt should be part of what you automate/control • LLLLLLLLLLLLLLLLLots of other projects rely on it • YYYYYYYYYYYYYYYYYou can harden it in a lot of ways • TTTTTTTTTTTTTTTTThere is a lot of things to discover!
  • 70. HomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomeworkHomework • SSSSSSSSSSSSSSSSSSH certificate authority • cccccccccccccccccommand= permitopen= • MMMMMMMMMMMMMMMMMatch blocks • sssssssssssssssssshfs • ……………………………………………
  • 71. Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?Any Question?
  • 72. ContactContactContactContactContactContactContactContactContactContactContactContactContactContactContactContactContact Julien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien PivottoJulien Pivotto julien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eujulien@inuits.eu @roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie@roidelapluie inuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuitsinuits https://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.euhttps://inuits.eu info@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.euinfo@inuits.eu +32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636+32 473 441 636