SlideShare a Scribd company logo
SSH Tricks and More!

 Presented by Kyle Young
Who am I?
• Just another computer technician
• Obtaining my macro degree in network
  administration from GRCC
• Planning on getting a Bachelors degree in Digital
  Forensics at FSU
• Been tinkering with computers since I was in middle
  school
• Became obsessed with Information Security in 2005
• Owner/Hoster of zitstif.no-ip.org
• Administrator on HITB forums
Read this book if you want to learn
            more about SSH!
SSH, The Secure Shell: The Definitive
Guide, 2nd Edition
By Daniel J. Barrett, Richard E. Silverman
,Robert G. Byrnes
Publisher: O'Reilly Media
Released: May 2005
Pages: 668
Presentation Note!

I WILL NOT BE COVERING THE PROPRIETARY VERSION OF SSH (Tectia)

SORRY! 
Why do a presentation on SSH tricks?
• SSH is one of my favorite protocols
• There have been plenty of articles and blog
  posts on the subject – I thought it was time to
  kind of aggregate these and add some of my
  own tips/tricks
What is SSH?
• Is it a shell? … No
• Is it a solution to all of your security
  problems? … No

“Secure Shell or SSH is a network protocol that
  allows data to be exchanged using a secure
  channel between two networked devices.” -
  en.wikipedia.org/wiki/SSh
SSH History
• SSH v1.X - Invented by Tatu Ylönen in 1995
• Created due to a password sniffing attack that
  took place at Helsinki University of Technology
• Created as a secure replacement for telnet,
  rlogin and rsh protocols
SSH and You!
• If you work in the information technology
  realm, there’s a good chance you have used SSH
  before.
• The SSH Client is natively available on
  practically all Non-Windows Operating Systems
• Can be more quick and dirty than Remote
  Desktop
• Easier to use on a phone than Remote Desktop
  (You may want to check out ‘mosh’
  http://mosh.mit.edu/ )
What can I use SSH for?
• For login to a shell on a remote host
• For executing a single command on a remote
  host (replacing rsh)
• Secure file transfer
• For forwarding or Tunneling
• Forwarding X from remote hosts
• The list goes on...
https://en.wikipedia.org/wiki/Secure_Shell#Usag
  e
SSH and Cyber Espionage
• Duqu Worm – (Nov 2011) Contained
  instructions to exploit a zero day vulnerability
  in OpenSSH 4.3 on CentOS systems
  – After compromising the system the worm then
    updated OpenSSH to version 5.8
Speaking of SCADA/SSH...
“Another day, another SCADA threat: ICS-CERT is
now warning utilities and other critical
infrastructure providers about potential brute-
force attacks against control systems with SSH
command-line access. “
- Kelly Jackson Higgins (darkreading.com)
Feb 06, 2012
Basic SSH Usage
Insecurity Issues With Default
                     Client Settings
Make sure your clients (and servers) are strictly using version 2
 Or they may be vulnerable to version downgrade attacks!

                                               You can also edit your ssh_config and change
                                               the directive :
                                               Protocol 2 
Downgrade attacks on SSH Clients

Downgrade attacks can 
be performed with ettercap-ng 
and ettercap-filters! 




                                 Image From http://openmaniak.com/
Connecting for the first time to an
      SSH Server: Do you know it’s safe?

If you’re very paranoid, you’ll want to verify the RSA fingerprint and randomart image 
with what fingerprint your given when connecting. 

To do so: On the server side you’ll have (usually requiring physical access to the 
Machine) You would need to do this:

sudo ssh-keygen -lvf /etc/ssh/ssh_host_rsa_key.pub

Then on your client side you want to edit your ssh_config file and set this option:

VisualHostKey yes


                                             http://www.itworld.com/it-managementstrateg
Connecting for the first time to an
SSH Server: Do you know it’s safe?




     One issue with this: “Obviously you need a
     secure method of getting verified copies of
     the fingerprint and randomart images for the
     computers you want to log into. ” - Carla 
     Schroder
                               http://www.itworld.com/it-managementstrategy/261500/16
One other thing.. Oh yeah Kippo can be ugly..
An attacker can capture your SSHv2 credentials using Kippo:

•To do so an attacker needs to be in your local area network or spoofing the IP address 
or domain name of the SSH server host that the victim is trying to connect to. 

•Setup Kippo to listen on the appropriate port

•If needed perform an ARP poisoning attack on the victim.

•Once the victim tries to connect they would most likely
get a mismatching fingerprint. However, with putty, an 
ignorant or hasty victim could simply click “YES”. 




                                            http://pauldotcom.com/wiki/index.php/Episod
OK I’m connected…am I still safe?
 Not necessarily
  - Some versions of the openssh-
 server  daemon will handle 
 password authentication in clear 
 text in memory! 

 Proof of concept: 
 http://zitstif.no-ip.org/capturessh2.txt
  

 #Tested on SSH-2.0-OpenSSH_4.7p1 
 Debian-8ubuntu1.2 
 #Tested on SSH-2.0-OpenSSH_5.1p1 
 Debian-5ubuntu1 
 #Tested on OpenSSH 5.2 (protocol 2.0) 
 Fedora 11
                                          Need to find the source on this 
                                          one! 
OK I’m connected…am I still safe?
Watch out on your client side: http://blog.diogomonica.com/post/3087360614
Poor man’s SSH keylogger! 
Locking Down The Server Side:
                 sshd_config is your friend!

•This may be debatable, but change 
your ssh server’s listening port to 
something different than port 22.

• Again.. Make sure your ssh server is 
strictly using Protocol Version 2

•Do not permit root login!

•Permit/Deny only specific users or 
groups! (AllowUsers/AllowGroups
Directive OR DenyUsers/DenyGroups)
                                   https://www.linux.com/learn/tutorials/305769-a
Oh yeah..a quick note on changing the
         default port for ssh




                    http://danielmiessler.com/blog/security-and-ob
Oh yeah..a quick note on changing the
         default port for ssh
Locking Down The Server Side:
                    sshd_config is your friend!

•Disable PasswordAuthentication and 
authenticate only using keys

•Configure an Idle Log out time period 
(ClientAliveInterval XXX )

•Limit what interface/addresses SSHD 
binds to

•Limit the amount of authentication tries 
(MaxAuthTries )                      https://www.linux.com/learn/tutorials/305769

                                            http://www.cyberciti.biz/tips/linux-unix-bsd-op
Locking Down The Server Side:
                sshd_config is your friend!

•Change the login grace time 
(LoginGraceTime)

•Oh yeah… disable empty passwords 
(Duh..) (PermitEmptyPasswords no)



                                 https://www.linux.com/learn/tutorials/305769

                                 http://www.cyberciti.biz/tips/linux-unix-bsd-op

                                 http://www.uptimemore.com/password-retry-
Locking Down The Server Side:
  Programs to help you lock down your server
•If applicable use iptables (or pf) 
to permit/deny specific IP 
addresses/ranges

List of programs to help ward off 
dictionary attacks/brute force 
attacks on 
http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-p
(#16)

•Setup port-knocking! 


                                       http://www.cyberciti.biz/tips/linux-unix-bsd-op
Quick tips for speeding up SSHD login
         sshd_config is your friend!
•Disable server side DNS look-
ups if you don’t need it. 
(UseDNS No)

If you’re not using PAM with 
SSH then disable PAM
(UsePAM No)




                                 http://www.cyberciti.biz/tips/linux-unix-bsd-op
Client side configuration tips
                 ssh_config is your friend!
Are you sick of constantly typing in your 
passwords (if you’re using passwords) when 
doing additional connections when you’ve 
already authenticated to your ssh server? 

Solution: Add this to your ssh_config file 
Host *
ControlPath ~/.ssh/master-%r@%h:%p
ControlMaster auto




                                       http://www.evilsoft.org/2009/10/23/stupid-
Client side configuration tips
                   ssh_config is your friend!
Save yourself some keystrokes!

ssh –C –D 1234 user@example.com -p 5432 

Edit your ssh_config file to something like this:

Host example example.com
   HostName example.com  
   User user
   Port 5432
DynamicForward 1234 
Compression Yes

Now you only need to type:
ssh example
                                         http://codeutopia.net/blog/2011/07/08/why-di
Client side configuration tips
                 ssh_config is your friend!
Are there any options to check for DNS 
spoofing? 

YES! 

CheckHostIP Yes

This will force ssh to do an additional check 
in the known_hosts file for the IP address of 
the server. 
For more information on configuring sshd_config
          and ssh_config, please see:
     man sshd_config && man ssh_config
Now for those beautiful client-sided one
        liners…(top 10 one liners from commandlinefu.com)
1


2



3



4



5
Client-sided one liners…(top 10 one liners from
                    commandlinefu.com)


6




7




8
Client-sided one liners…(top 10 one liners from
                     commandlinefu.com)

9




10
Client-sided one liners…(more awesome one liners from
                   commandlinefu.com)
Client-sided one liners…(more awesome one liners from
                   commandlinefu.com)
For more awesome one-liners from
      commandlinefu.com:
More awesome one-liners:
http://diogomelo.net/blog/10/ssh-tricks




Don’t want to expose remote desktop via your firewall? You can still use it through ssh!:
ssh –L 3389:192.168.1.100:3389 user@site.com 

Put the ssh client in a very verbose mode for troubleshooting/debugging:
ssh –vvv user@site.com 




http://linuxaria.com/howto/trucchi-con-ssh?lang=en
More awesome one-liners:




http://www.linuxjournal.com/article/6602?page=0,1



Pipe webcam over ssh: 



http://unix.stackexchange.com/questions/2302/can-i-pipe-dev-video-o
Client-sided one liners: Fun with the ‘-t’
                      option
Any programs that need a pseudo terminal screen to work and you need run quickly, use 
-t.

Examples:

ssh –t user@example.com “python”
ssh –t user@example.com “irb”
ssh –t user@example.com “ssh anotheruser@anotherhost.com”
ssh –t user@example.com “msfconsole” 
ssh –t user@example.com “screen”
ssh  -t user@example.com “vi”
Client-sided one liners: Fun with reverse
                    connections
Don’t have metasploit or any fancy info-sec security tools on your device that is connected 
to a LAN, but this device still has an SSH client on it? 

NO PROBLEM!

Target host: 192.168.1.102
Target port: 445
Payload port: 4444

ssh –t –R  192.168.1.102:445:127.0.0.1:4445 –R 192.168.1.102:4444:127.0.0.1:4444 
attacker@penbox.org “msfconsole”

Then through metasploit  on your remote host you would point your attacks towards your 
loopback interface 
Client-sided one liners (Poor man’s VPN/proxy)




This will bind a SOCKS server to port 9050 on the interface 192.168.1.100 
Client-sided one liners (Poor man’s VPN/proxy)




OK big deal.. I know that.. What’s special about it? 
Client-sided one liners (Poor man’s VPN/proxy)




What this means: 

•You can now tunnel traffic securely between you the client, and example.com
• If example.com’s subnet is 10.1.10.255, you can now access resources in that 
subnet via your tunnel, hence why this is a poorman’s VPN.
•You can use programs like proxychains in tandem with SOCKS
•NOTE: example.com’s hosts file (/etc/hosts) does affect the DNS name resolution of 
the SOCKS client  
Client-sided one liners (Poor man’s VPN/proxy)
Programs that play nicely with proxychains: 

rdesktop
netcat
socat
nmap 
hping
telnet
openvas
nessus
hydra
wget
ssh
metasploit (though not needed) (set Proxies socks5:localhost:1234) 
ncrack
...(The list goes on)

Almost any application that works on *nix and relies on TCP/IP
Ways of setting up sshd the quick and
                     dirty way…
Scenario 1:

Are you doing a pentest and you’re able to find a router that is compatible with openwrt  or 
dd-wrt? 

Upload it! Most versions of openwrt and dd-wrt support SSHD

Scenario 2:

You’ve popped a shell on a Windows box and you’d like to setup an SSHD server:

Copssh_3.1.4_Installer.exe /S 

Copssadm --command activeuser –user USERNAME –shell /bin/bash 
Ways of setting up sshd the quick and
                     dirty way…
Meterpreter from the metasploit project now has a meterpreter script that can deploy an 
openssh server on Windows victims.  (I must admit, the few times I’ve tried it, it has never 
worked for me!) 
SSH and Window$
SSH Clients on Windows:
Putty, plink, psftp, ssh (cygwin) (there are a bunch.. 
http://en.wikipedia.org/wiki/Comparison_of_SSH_clients#Platform)

Probably one of the best guides for installing Cygwin w/ an openssh 
server on Windows:
http://pigtail.net/LRP/printsrv/cygwin-sshd.html

NOTE: Follow the steps very closely! 

Minimal/Easy Install options of cygwin with sshd: 
http://sshwindows.sourceforge.net/
https://www.itefix.no/i2/copssh

For X11 forwarding over SSH, Install Xming and use putty: 
http://sourceforge.net/projects/xming/
 
Programming/Automating SSH
Examples of languages that you can use for automating SSH:
Programming/Automating SSH
Python Example: 




Very good guide on paramiko: 
http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/
SSH and IPV6
Very good guide for getting around with IPv6 and show examples of SSH 
usage:

http://www.enterprisenetworkingplanet.com/netsp/article.php/3634596/Getting-Around-IPv6.htm

Things to check:

•Use ping6 to ping at least your lookback interface ::1
•Use ping6 to ping ipv6 domain names: (i.e. ipv6.google.com)
•Make sure your IPV6 server is setup to listen on an IPV6 address 
(NOTE: 0.0.0.0 in IPV6 is ::: )

Simple example using ssh and ipv6:

ssh user@2001:4860:800a::93
Live Demo: SSH/Miredo/IPV6

           Thanks Mubix! (
http://www.room362.com/blog/2010/9/24/rev
                  )
?
Questions?
FIN!

Postscript: man ssh

More Related Content

PPTX
Abusing Microsoft Kerberos - Sorry you guys don't get it
PPT
PDF
PDF
Tatu: ssh as a service
PDF
SSH Tunneling Recipes
PDF
Linux advanced privilege escalation
PDF
Breaking Vaults - Stealing Lastpass Protected Secrets by Martin Vigo
PDF
How fun of privilege escalation Red Pill2017
Abusing Microsoft Kerberos - Sorry you guys don't get it
Tatu: ssh as a service
SSH Tunneling Recipes
Linux advanced privilege escalation
Breaking Vaults - Stealing Lastpass Protected Secrets by Martin Vigo
How fun of privilege escalation Red Pill2017

What's hot (19)

PDF
Privilege escalation from 1 to 0 Workshop
PDF
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
PPTX
Cloud Device Insecurity
PDF
Ssh and sshfp dns records v04
PDF
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
PDF
NSC #2 - D2 02 - Benjamin Delpy - Mimikatz
PDF
OpenSSH: keep your secrets safe
PPTX
Kerberos, NTLM and LM-Hash
PDF
OpenSMTPD: we deliver !!
PDF
Introduction to Linux Privilege Escalation Methods
PPTX
BSides Edinburgh 2017 - TR-06FAIL and other CPE Configuration Disasters
PPTX
So you want to be a security expert
PPTX
Steelcon 2015 - 0wning the internet of trash
PPTX
Nginx warhead
PDF
TLS Interception considered harmful (Chaos Communication Camp 2015)
PDF
Если нашлась одна ошибка — есть и другие. Один способ выявить «наследуемые» у...
PDF
Zi nginx conf_2015
PDF
Aide 2014 - Fundamentals of Linux Privilege Escalation
Privilege escalation from 1 to 0 Workshop
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Cloud Device Insecurity
Ssh and sshfp dns records v04
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
NSC #2 - D2 02 - Benjamin Delpy - Mimikatz
OpenSSH: keep your secrets safe
Kerberos, NTLM and LM-Hash
OpenSMTPD: we deliver !!
Introduction to Linux Privilege Escalation Methods
BSides Edinburgh 2017 - TR-06FAIL and other CPE Configuration Disasters
So you want to be a security expert
Steelcon 2015 - 0wning the internet of trash
Nginx warhead
TLS Interception considered harmful (Chaos Communication Camp 2015)
Если нашлась одна ошибка — есть и другие. Один способ выявить «наследуемые» у...
Zi nginx conf_2015
Aide 2014 - Fundamentals of Linux Privilege Escalation
Ad

Similar to Presentation nix (20)

PDF
An introduction to SSH
PPT
Secure shell ppt
PPTX
PPT
Introduction to SSH
PPTX
Shmoocon Epilogue 2013 - Ruining security models with SSH
PDF
Dssh @ Confidence, Prague 2010
PDF
0696-ssh-the-secure-shell.pdf
PPTX
A presentation on SSH (Secure Shell or Secure Socket Shell)
PPTX
Unsecuring SSH
PPTX
Ssh (The Secure Shell)
PDF
SSH - Secure Shell
KEY
Intro to SSH
PPTX
SSh_part_1.pptx
PPT
SSH.ppt
PDF
SSH how to 2011
PPT
Ssh
PDF
tutorial-ssh.pdf
PPTX
PPT
Secure shell protocol
PDF
Windowshadoop
An introduction to SSH
Secure shell ppt
Introduction to SSH
Shmoocon Epilogue 2013 - Ruining security models with SSH
Dssh @ Confidence, Prague 2010
0696-ssh-the-secure-shell.pdf
A presentation on SSH (Secure Shell or Secure Socket Shell)
Unsecuring SSH
Ssh (The Secure Shell)
SSH - Secure Shell
Intro to SSH
SSh_part_1.pptx
SSH.ppt
SSH how to 2011
Ssh
tutorial-ssh.pdf
Secure shell protocol
Windowshadoop
Ad

More from fangjiafu (20)

PDF
Wce internals rooted_con2011_ampliasecurity
PDF
Oracle forensics 101
PDF
Understanding and selecting_dsp_final
PDF
Wce12 uba ampliasecurity_eng
PDF
Ddos analizi
PDF
Bypass dbms assert
PDF
Cursor injection
PDF
Create user to_sysdba
PPT
Presentation nix
PDF
Layer 7 ddos
PDF
Tlsoptimizationprint 120224194603-phpapp02
PDF
Crypto hlug
PDF
PDF
Rr 7944
PDF
Proper passwordhashing
PDF
Burp suite injection中的应用by小冰
PDF
Oech03
PDF
2008 07-24 kwpm-threads_and_synchronization
PDF
Unit07
PDF
Unit05
Wce internals rooted_con2011_ampliasecurity
Oracle forensics 101
Understanding and selecting_dsp_final
Wce12 uba ampliasecurity_eng
Ddos analizi
Bypass dbms assert
Cursor injection
Create user to_sysdba
Presentation nix
Layer 7 ddos
Tlsoptimizationprint 120224194603-phpapp02
Crypto hlug
Rr 7944
Proper passwordhashing
Burp suite injection中的应用by小冰
Oech03
2008 07-24 kwpm-threads_and_synchronization
Unit07
Unit05

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Electronic commerce courselecture one. Pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
The AUB Centre for AI in Media Proposal.docx
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25 Week I
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
Electronic commerce courselecture one. Pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
Understanding_Digital_Forensics_Presentation.pptx

Presentation nix