SlideShare a Scribd company logo
OpenSSH
tomas.corej@websupport.sk
      @tomas_corej
OpenSSH
● nastroj pre bezpecne, vzdialene
  prihlasovanie
● prepisana verzia originalneho SSH
  nastroja
● priklad flexibilneho nastroja pouzitelneho
  na ovela viac nez len vzdialene
  prihlasovanie
● nahrada za telnet, ftp, rlogin
●
Od zaciatku




             pesnik:~$ ssh testor

                      alebo

pesnik:~$ ln -s /usr/bin/ssh-argv0 $HOME/bin/testor
                   pesnik:~$ testor
Od zaciatku


pesnik:~$ ssh testor
user@testor password: ^C
pesnik:~$ ssh-keygen
pesnik:~$ ssh-copy-id testor
Now try logging into the machine, with "ssh 'testor'", and check in:

 ~/.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
Od zaciatku


pesnik:~$ ssh testor
Warning: the RSA host key for 'testor' differs from the key for the IP
address '37.9.170.2'
Offending key for IP in /home/tomas.corej/.ssh/known_hosts:57
Matching host key in /home/tomas.corej/.ssh/known_hosts:875
You have mail.
Last login: Thu Jul 11 00:12:57 2012 from services
testor:~$ ^D
pesnik: ~$ ssh-keygen -R 37.9.170.2
Od zaciatku


pesnik:~$ ssh testor
You have mail.
Last login: Thu Jul 11 00:12:57 2012 from pesnik
testor:~$
Od zaciatku


pesnik:~$ ssh testor
You have mail.
Last login: Thu Jul 11 00:12:57 2012 from services
testor:~$
testor:~$ ~?
Supported escape sequences:
 ~. - terminate connection (and any multiplexed sessions)
 ~B - send a BREAK to the remote system
 ~C - open a command line
 ~R - Request rekey (SSH protocol 2 only)
 ~^Z - suspend ssh
 ~# - list forwarded connections
 ~& - background ssh (when waiting for connections to terminate)
 ~? - this message
 ~~ - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)
Pouzitelne v skriptoch


pesnik:~$ ssh testor /bin/true && echo ok
ok

if ssh testor prikaz; then
...
fi
Nechce sa mi pouzit scp


pesnik:~$ dllllhyyy prikaz | ssh testor "cat >
remotefile"

pesnik:~$ mysqldump -uroot -p db | ssh testor "gzip -
> db.gz"

pesnik:~$ mysqldump -uroot -p db |gzip - | ssh testor
"cat > db.gz"
pesnik:~$ cat zoznam | ssh testor "while read input;
do prikaz $input $USER;done"
X11 jednoducho

pesnik:~$ ssh -X testor firefox


pesnik:~$ ssh -X testor.vpn gnome-terminal

pesnik:~$ ssh -X testor.vpn xeyes
Agent forwarding

tomas.corej@pesnik:~$ ssh-add -l
2048 f8:c6:6a:f4:ca:ee:0e:57:86:ed:f1:4b:ec:d3:84:ba /home/tomas.corej/.ssh/id_rsa (RSA)


tomas.corej@pesnik:~$ ssh -A testor
tomas.corej@testor:~$ ssh-add -l
2048 f8:c6:6a:f4:ca:ee:0e:57:86:ed:f1:4b:ec:d3:84:ba /home/tomas.corej/.ssh/id_rsa (RSA)


tomas.corej@pesnik:~$ ssh -A testor2
mozne bezpecnostne riziko
adresar s unixovym socketom pristupny v /tmp
moze viest k chybam hlavne pri spustani cron skriptov
SOCKS proxy a tunelovanie

pesnikl:~$ ssh -D 3128 testor


     -L[bind_address:]port:host:hostport Request local forward
      -R[bind_address:]port:host:hostport Request remote forward
     -D[bind_address:]port            Request dynamic forward




1.
Host *
     User root
     ForwardAgent yes
      ForwardX11 yes
     ConnectTimeout=20
     PreferredAuthentications=publickey,password,keyboard-
interactive
     StrictHostKeyChecking=no
     ControlMaster auto
     ControlPath ~/.ssh/sockets/%r@%h:%p
     SendEnv BASH_ENV
     IdentityFile ~/.ssh/id_rsa
      IdentityFile ~/.ssh/customers_vps
     Compression yes
Host abcd
     IdentityFile ~/.ssh/abcd.pub




                            Ulozme si to vsetko do $HOME/.ssh/config
level++
ProxyCommand

● moze to byt cokolvek, dolezite je, aby to
  spracovavalo STDIN a STDOUT

  ssh -o ProxyCommand="$HOME/.ssh/gateway.sh %h %p" testor


● Nahradzuje %h, %p a %r
● pristup cez prostrednika
 ssh -o ProxyCommand="ssh user@testor nc %h %p" user@192.
                    168.1.2 "uname -a"

● parameter -W
● riziko DOS
Multiplexovanie SSH spojeni
● pri castom generovani SSH spojeni a vo
  velkom mnozstve
● skracuje cas a znizuje overhead (0.2s vs
  0.014s)
● config

ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h:%p
● ovladanie cez -O check,forward,stop,exit
Multiplexovanie SSH spojeni
pesnik:~$ ssh testor
You have mail.
Last login: Thu Jul 11 00:12:57 2012 from pesnik
testor:~$
testor:~$ ~^Z

pesnik:~$ cd ~/.ssh/sockets
pesnik:~$ ~/.ssh/sockets$ ls
user@testor:22
pesnik:~$ ssh -O check user@testor
Master running (pid=22797)

pesnik:~$ fg
testor:~$
Subsystemy
● ina forma spustania remotnych prikazov
● SFTP je subsystem
● moze ist aj o internu funkcionalitu (sftp a
  chroot)
● server sshd_config

       Subsystem backup /root/bin/backupcmd
● ssh klient
               ssh -s backup root@testor
DNS SSHFP
● rozsireny sposob verifikacie odtlackov
● fingerprinty SSHD je mozne ulozit aj do
  DNS zaznamov
● VerifyHostKeyDNS yes|ask|no
Sukromne kluce
● sukromne kluce sa nachadzaju v
  $HOME/id_rsa (defaulne)
● Kluce je mozne dodatocne specifikovat
 no-port-forwarding,no-user-rc,no-X11-forwarding,no-pty,
 command="/bin/nc $SSH_ORIGINAL_COMMAND" ssh-rsa
 AAAAB3NzMMAND" ssh-rsa AAAAB3Nza....


● $SSH_ORIGINAL_COMMAND obsahuje
  text prikazu
               ssh root@testor prikaz
OpenSSH-lpk
● OpenSSH-lpk patch
  ○ sposobuje dotazovanie sa na verejne kluce na
    LDAP server
Tomáš Čorej - OpenSSH
factotum
● prispevok zo sveta operacneho systemu
  Plan9
Tomáš Čorej - OpenSSH

More Related Content

PDF
Ssh cookbook
PDF
Pf: the OpenBSD packet filter
PDF
Redis & ZeroMQ: How to scale your application
PDF
OpenSSH: keep your secrets safe
PDF
Bash Scripting Workshop
PDF
OpenSMTPD: we deliver !!
PDF
Relayd: a load balancer for OpenBSD
PPTX
Cis 216 – shell scripting
Ssh cookbook
Pf: the OpenBSD packet filter
Redis & ZeroMQ: How to scale your application
OpenSSH: keep your secrets safe
Bash Scripting Workshop
OpenSMTPD: we deliver !!
Relayd: a load balancer for OpenBSD
Cis 216 – shell scripting

What's hot (20)

PPTX
Linux tech talk
PPTX
Process monitoring in UNIX shell scripting
PDF
Devinsampa nginx-scripting
PDF
Border Patrol - Count, throttle, kick & ban in perl
PDF
Linux Commands - Cheat Sheet
PDF
tdc2012
PDF
Combine vs RxSwift
PDF
Redis as a message queue
PDF
OWASP Proxy
PDF
Steam Learn: Composer
PDF
PPTX
Linux networking
DOCX
Basic command for linux
PDF
How to admin
PDF
Service intergration
PDF
Gitosis on Mac OS X Server
PPTX
Install git and drush on Godaddy shared hosting
PDF
uerj201212
TXT
Crack.ba
PDF
Linux tech talk
Process monitoring in UNIX shell scripting
Devinsampa nginx-scripting
Border Patrol - Count, throttle, kick & ban in perl
Linux Commands - Cheat Sheet
tdc2012
Combine vs RxSwift
Redis as a message queue
OWASP Proxy
Steam Learn: Composer
Linux networking
Basic command for linux
How to admin
Service intergration
Gitosis on Mac OS X Server
Install git and drush on Godaddy shared hosting
uerj201212
Crack.ba
Ad

Similar to Tomáš Čorej - OpenSSH (20)

PDF
Ssh cookbook v2
PDF
An introduction to SSH
PDF
Advanced open ssh
KEY
Intro to SSH
PDF
OpenSSH tricks
PDF
SSH: Seguranca no Acesso Remoto
PDF
Puppet @ Seat
ODP
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
DOC
How to send files to remote server via ssh in php
PDF
tutorial-ssh.pdf
TXT
Linuxserver harden
PDF
PDF
One-Liners to Rule Them All
PDF
Python build your security tools.pdf
TXT
Cluster setup multinode_aws
PDF
Importance of SSHFP for Network Devices
PDF
Importance of sshfp and configuring sshfp for network devices
PPTX
SSH for pen-testers
DOCX
Really useful linux commands
ZIP
Sshstuff
Ssh cookbook v2
An introduction to SSH
Advanced open ssh
Intro to SSH
OpenSSH tricks
SSH: Seguranca no Acesso Remoto
Puppet @ Seat
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
How to send files to remote server via ssh in php
tutorial-ssh.pdf
Linuxserver harden
One-Liners to Rule Them All
Python build your security tools.pdf
Cluster setup multinode_aws
Importance of SSHFP for Network Devices
Importance of sshfp and configuring sshfp for network devices
SSH for pen-testers
Really useful linux commands
Sshstuff
Ad

More from webelement (6)

PDF
WebElement #22: Peter Slivka - Úvod do AWS
PDF
WebElement #20: Ondrej Svitek - Hacking Life With Git
PPTX
Ján Kmeťko - NoSQL a distribuované databázy – pohľad zhora na konzistentnosť ...
PDF
Lukáš Šabľa - Vim
PPTX
Martin Strýček - Ako začať s MongoDB
PDF
Marek Lichtner - Používať alebo nepoužívať ORM vo webových aplikáciách?
WebElement #22: Peter Slivka - Úvod do AWS
WebElement #20: Ondrej Svitek - Hacking Life With Git
Ján Kmeťko - NoSQL a distribuované databázy – pohľad zhora na konzistentnosť ...
Lukáš Šabľa - Vim
Martin Strýček - Ako začať s MongoDB
Marek Lichtner - Používať alebo nepoužívať ORM vo webových aplikáciách?

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
cuic standard and advanced reporting.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PPT
Teaching material agriculture food technology
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Modernizing your data center with Dell and AMD
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
MYSQL Presentation for SQL database connectivity
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
Approach and Philosophy of On baking technology
Dropbox Q2 2025 Financial Results & Investor Presentation
cuic standard and advanced reporting.pdf
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
Teaching material agriculture food technology
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Building Integrated photovoltaic BIPV_UPV.pdf
Modernizing your data center with Dell and AMD
20250228 LYD VKU AI Blended-Learning.pptx

Tomáš Čorej - OpenSSH

  • 2. OpenSSH ● nastroj pre bezpecne, vzdialene prihlasovanie ● prepisana verzia originalneho SSH nastroja ● priklad flexibilneho nastroja pouzitelneho na ovela viac nez len vzdialene prihlasovanie ● nahrada za telnet, ftp, rlogin ●
  • 3. Od zaciatku pesnik:~$ ssh testor alebo pesnik:~$ ln -s /usr/bin/ssh-argv0 $HOME/bin/testor pesnik:~$ testor
  • 4. Od zaciatku pesnik:~$ ssh testor user@testor password: ^C pesnik:~$ ssh-keygen pesnik:~$ ssh-copy-id testor Now try logging into the machine, with "ssh 'testor'", and check in: ~/.ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
  • 5. Od zaciatku pesnik:~$ ssh testor Warning: the RSA host key for 'testor' differs from the key for the IP address '37.9.170.2' Offending key for IP in /home/tomas.corej/.ssh/known_hosts:57 Matching host key in /home/tomas.corej/.ssh/known_hosts:875 You have mail. Last login: Thu Jul 11 00:12:57 2012 from services testor:~$ ^D pesnik: ~$ ssh-keygen -R 37.9.170.2
  • 6. Od zaciatku pesnik:~$ ssh testor You have mail. Last login: Thu Jul 11 00:12:57 2012 from pesnik testor:~$
  • 7. Od zaciatku pesnik:~$ ssh testor You have mail. Last login: Thu Jul 11 00:12:57 2012 from services testor:~$ testor:~$ ~? Supported escape sequences: ~. - terminate connection (and any multiplexed sessions) ~B - send a BREAK to the remote system ~C - open a command line ~R - Request rekey (SSH protocol 2 only) ~^Z - suspend ssh ~# - list forwarded connections ~& - background ssh (when waiting for connections to terminate) ~? - this message ~~ - send the escape character by typing it twice (Note that escapes are only recognized immediately after newline.)
  • 8. Pouzitelne v skriptoch pesnik:~$ ssh testor /bin/true && echo ok ok if ssh testor prikaz; then ... fi
  • 9. Nechce sa mi pouzit scp pesnik:~$ dllllhyyy prikaz | ssh testor "cat > remotefile" pesnik:~$ mysqldump -uroot -p db | ssh testor "gzip - > db.gz" pesnik:~$ mysqldump -uroot -p db |gzip - | ssh testor "cat > db.gz" pesnik:~$ cat zoznam | ssh testor "while read input; do prikaz $input $USER;done"
  • 10. X11 jednoducho pesnik:~$ ssh -X testor firefox pesnik:~$ ssh -X testor.vpn gnome-terminal pesnik:~$ ssh -X testor.vpn xeyes
  • 11. Agent forwarding tomas.corej@pesnik:~$ ssh-add -l 2048 f8:c6:6a:f4:ca:ee:0e:57:86:ed:f1:4b:ec:d3:84:ba /home/tomas.corej/.ssh/id_rsa (RSA) tomas.corej@pesnik:~$ ssh -A testor tomas.corej@testor:~$ ssh-add -l 2048 f8:c6:6a:f4:ca:ee:0e:57:86:ed:f1:4b:ec:d3:84:ba /home/tomas.corej/.ssh/id_rsa (RSA) tomas.corej@pesnik:~$ ssh -A testor2 mozne bezpecnostne riziko adresar s unixovym socketom pristupny v /tmp moze viest k chybam hlavne pri spustani cron skriptov
  • 12. SOCKS proxy a tunelovanie pesnikl:~$ ssh -D 3128 testor -L[bind_address:]port:host:hostport Request local forward -R[bind_address:]port:host:hostport Request remote forward -D[bind_address:]port Request dynamic forward 1.
  • 13. Host * User root ForwardAgent yes ForwardX11 yes ConnectTimeout=20 PreferredAuthentications=publickey,password,keyboard- interactive StrictHostKeyChecking=no ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h:%p SendEnv BASH_ENV IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/customers_vps Compression yes Host abcd IdentityFile ~/.ssh/abcd.pub Ulozme si to vsetko do $HOME/.ssh/config
  • 15. ProxyCommand ● moze to byt cokolvek, dolezite je, aby to spracovavalo STDIN a STDOUT ssh -o ProxyCommand="$HOME/.ssh/gateway.sh %h %p" testor ● Nahradzuje %h, %p a %r ● pristup cez prostrednika ssh -o ProxyCommand="ssh user@testor nc %h %p" user@192. 168.1.2 "uname -a" ● parameter -W ● riziko DOS
  • 16. Multiplexovanie SSH spojeni ● pri castom generovani SSH spojeni a vo velkom mnozstve ● skracuje cas a znizuje overhead (0.2s vs 0.014s) ● config ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h:%p ● ovladanie cez -O check,forward,stop,exit
  • 17. Multiplexovanie SSH spojeni pesnik:~$ ssh testor You have mail. Last login: Thu Jul 11 00:12:57 2012 from pesnik testor:~$ testor:~$ ~^Z pesnik:~$ cd ~/.ssh/sockets pesnik:~$ ~/.ssh/sockets$ ls user@testor:22 pesnik:~$ ssh -O check user@testor Master running (pid=22797) pesnik:~$ fg testor:~$
  • 18. Subsystemy ● ina forma spustania remotnych prikazov ● SFTP je subsystem ● moze ist aj o internu funkcionalitu (sftp a chroot) ● server sshd_config Subsystem backup /root/bin/backupcmd ● ssh klient ssh -s backup root@testor
  • 19. DNS SSHFP ● rozsireny sposob verifikacie odtlackov ● fingerprinty SSHD je mozne ulozit aj do DNS zaznamov ● VerifyHostKeyDNS yes|ask|no
  • 20. Sukromne kluce ● sukromne kluce sa nachadzaju v $HOME/id_rsa (defaulne) ● Kluce je mozne dodatocne specifikovat no-port-forwarding,no-user-rc,no-X11-forwarding,no-pty, command="/bin/nc $SSH_ORIGINAL_COMMAND" ssh-rsa AAAAB3NzMMAND" ssh-rsa AAAAB3Nza.... ● $SSH_ORIGINAL_COMMAND obsahuje text prikazu ssh root@testor prikaz
  • 21. OpenSSH-lpk ● OpenSSH-lpk patch ○ sposobuje dotazovanie sa na verejne kluce na LDAP server
  • 23. factotum ● prispevok zo sveta operacneho systemu Plan9