SSH The Secure Shell



Similar documents
SSH, SCP, SFTP, Denyhosts. Süha TUNA Res. Assist.

OpenSSH: Secure Shell

SSH and FTP on Ubuntu WNYLUG Neal Chapman 09/09/2009

Secure Shell. The Protocol

Know your tools SSH. Dariusz Puchalak Dariusz_Puchalak < at > ProbosIT.pl

Secure File Transfer Installation. Sender Recipient Attached FIles Pages Date. Development Internal/External None 11 6/23/08

Pro OpenSSH. Michael Stahnke. Apress* =# # w^ l&l ## frsft. *,«.,*

File transfer clients manual File Delivery Services

TS-800. Configuring SSH Client Software in UNIX and Windows Environments for Use with the SFTP Access Method in SAS 9.2, SAS 9.3, and SAS 9.

TELE 301 Network Management. Lecture 16: Remote Terminal Services

Secure access to the DESY network using SSH

Using SFTP on the z/os Platform

Connectivity using ssh, rsync & vsftpd

Contents. Part 1 SSH Basics 1. Acknowledgments About the Author Introduction

Defeating Firewalls : Sneaking Into Office Computers From Home

10/23/12. Fundamentals of Linux Platform Security. Linux Platform Security. Roadmap. Security Training Course. Module 9 Application Security

What IT Auditors Need to Know About Secure Shell. SSH Communications Security

Configuring SSH and Telnet

Overview SSL/TLS HTTPS SSH. TLS Protocol Architecture TLS Handshake Protocol TLS Record Protocol. SSH Protocol Architecture SSH Transport Protocol

Security Configuration Guide P/N Rev A05

An Overview of the Secure Shell (SSH)

Chapter 17. Transport-Level Security

IBM eserver iseries ITSO Technical Forum 2005

F-Secure SSH. for Windows. User s Guide

CASHNet Secure File Transfer Instructions

SSH! Keep it secret. Keep it safe

Install and configure SSH server

Exam Questions SY0-401

File Transfer Protocol (FTP) & SSH

Pragma FortressSSH 5.0

Implementing Secure Shell

Overview. Remote access and file transfer. SSH clients by platform. Logging in remotely

If you prefer to use your own SSH client, configure NG Admin with the path to the executable:

Unifying Information Security. Implementing TLS on the CLEARSWIFT SECURE Gateway

finger, ftp, host, hostname, mesg, rcp, rlogin, rsh, scp, sftp, slogin, ssh, talk, telnet, users, w, walla, who, write,...

Configure Backup Server for Cisco Unified Communications Manager

Cornerstones of Security

Easy Setup Guide 1&1 CLOUD SERVER. Creating Backups. for Linux

IBM WebSphere Application Server Version 7.0

A SHORT INTRODUCTION TO BITNAMI WITH CLOUD & HEAT. Version

Topics in Network Security

F-Secure. Securing the Mobile Distributed Enterprise. F-Secure SSH User's and Administrator's Guide

Configuring CSS Remote Access Methods

Redpaper. Securing Communications with OpenSSH on IBM i5/os. Front cover. ibm.com/redbooks. Learn how to install, configure, and use SSH with i5/os

File Transfer Examples. Running commands on other computers and transferring files between computers

Guide to the Configuration and Use of SFTP Clients for Uploading Digital Treatment Planning Data to IROC RI

SSL Tunnels. Introduction

GPFS and Remote Shell

Understanding Secure Shell Host Keys

NETWORK SECURITY HACKS

How to Tunnel Remote Desktop using SSH (Cygwin) for Windows XP (SP2)

athenahealth Interface Connectivity SSH Implementation Guide

CA ehealth. Remote Poller Guide. r6.1

ProxyCap Help. Table of contents. Configuring ProxyCap Proxy Labs

Secure File Multi Transfer Protocol Design

Guideline for setting up a functional VPN

Securing Windows Remote Desktop with CopSSH

CS 665: Computer System Security. Network Security. Usage environment. Sources of vulnerabilities. Information Assurance Module

WinSCP PuTTY as an alternative to F-Secure July 11, 2006

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

Cloud Control Panel (CCP) Installation Guide

CS 640 Introduction to Computer Networks. Network security (continued) Key Distribution a first step. Lecture24

MobaXTerm: A good gnome-terminal like tabbed SSH client for Windows / Windows Putty Tabs Alternative

Secure Shell (SSH) Protocol

SO114 - Solaris 10 OE Network Administration

What is a Firewall? Computer Security. Firewalls. What is a Firewall? What is a Firewall?

SSSD and OpenSSH Integration

2 Advanced Session... Properties 3 Session profile... wizard. 5 Application... preferences. 3 ASCII / Binary... Transfer

Intro to Firewalls. Summary

CHAPTER 7 SSL CONFIGURATION AND TESTING

Parallels Plesk Panel

Virtual private network. Network security protocols VPN VPN. Instead of a dedicated data link Packets securely sent over a shared network Internet VPN

Introduction à OpenSSH

Tera Term Telnet. Introduction

Methods available to GHP for out of band PUBLIC key distribution and verification.

Parallels Plesk Panel. VPN Module for Parallels Plesk Panel 10 for Linux/Unix Administrator's Guide. Revision 1.0

Solution of Exercise Sheet 5

Using sftp in Informatica PowerCenter

SSH Secure Shell. Administrator s Guide

My FreeScan Vulnerabilities Report

Online Banking for Business Secure FTP with SSH (Secure Shell) USER GUIDE

SERVER HARDENING. Presented by: Daniel Waymel and Corrin Thompson at TexSAW 2014 at the University of Texas at Dallas

STERLING SECURE PROXY. Raj Kumar Integration Management, Inc.

TELE 301 Network Management. Lecture 17: File Transfer & Web Caching

ASX SFTP External User Guide

Securing Windows Remote Desktop with CopSSH

Chapter 7 Transport-Level Security

OS/390 Firewall Technology Overview

HONEYD (OPEN SOURCE HONEYPOT SOFTWARE)

Firewalls. Chapter 3

COURCE TITLE DURATION LPI-202 Advanced Linux Professional Institute 40 H.

How to Tunnel Remote Desktop Through SSH on a Windows Computer

Access Instructions for United Stationers ECDB (ecommerce Database) 2.0

Transcription:

June 26, 2007 UniForum Chicago SSH The Secure Shell Hemant Shah shahhe@gmail.com Platform: Linux and Unix

What is SSH? June 26, 2007 Copyright Hemant Shah 2

What is SSH? The Secure Shell It is a protocol not a product Software based approach to network security Encrypts the data sent between the computers Client/Server architecture Comes with all Linux distribution, Mac OS X, AIX, Sun Solaris, OpenBSD and other Unix variants Ported to other operating systems, such as Windows, Palm OS, Amiga, etc. Other clients, such as, scp, sftp, etc. are also available Replacement for telnet, rlogin, rsh, rcp, ftp, etc. June 26, 2007 Copyright Hemant Shah 3

What is SSH Not June 26, 2007 Copyright Hemant Shah 4

What SSH is NOT It is not a true shell like csh, ksh, sh, etc. It is not a command interpreter It creates secure channel for running commands on remote computer It is not a complete security solution It will not protect against trojans, viruses, etc. June 26, 2007 Copyright Hemant Shah 5

History June 26, 2007 Copyright Hemant Shah 6

History In 1995, Tatu Ylönen, a researcher at Helsinki University designed the first version of the protocol (now called SSH-1) In July of 1995, he released SSH1 as free software In December of 1995 he formed SSH Communication Security to market and develop SSH In 1996 SSH-2 was developed, it was incompatible with SSH-1 SCS released SSH-2 in 1998 and had more restrictive license IETF formed group called SECSH to standardize the protocol OpenSSH, free implementation of SSH-2 protocol was released from OpenBSD project. In 2006 IETF SECSH group released SSH-2 as internet standard (RFC 4251) June 26, 2007 Copyright Hemant Shah 7

Terminology June 26, 2007 Copyright Hemant Shah 8

Terminology SSH - Generic term used for SSH protocols ssh - Client command for running remote command sshd - Server program SSH-1 - Version 1 of the protocol SSH-2 - Version 2 of the protocol OpenSSH - Product from open BSD project June 26, 2007 Copyright Hemant Shah 9

SSH Architecture June 26, 2007 Copyright Hemant Shah 10

SSH Architecture ssh client ssh server Authentication Network Anw@dc%9r&6cbditop*dekisn@h??? June 26, 2007 Copyright Hemant Shah 11

SSH Layers ssh-connection Session multiplexing, X11 and port forwarding, remote command execution, SOCKS proxy, etc. Application Layer Transport Layer Internet Layer Network Access Layer ssh-userauth User authentication using public key, password, host based, etc. ssh-transport Initial key exchange and server authentication, setup encryption TCP IP Ethernet June 26, 2007 Copyright Hemant Shah 12

SSH Connection Sequence A cryptographic handshake is made with the server The connection between client and remote server is encrypted using symmetric cipher Client authenticates itself Client can now interact safely with remote server over encrypted connection June 26, 2007 Copyright Hemant Shah 13

SSH Features Strong encryption Strong authentication Authorization Integrity of communication Forwarding or tunneling June 26, 2007 Copyright Hemant Shah 14

SSH will protect against Eavesdropping of data transmitted over the network Manipulation of data at intermediate elements in the network (e.g. routers) IP address spoofing where an attack hosts pretends to be a trusted host by sending packets with the source address of the trusted host DNS spoofing of trusted host names/ip addresses IP source routing June 26, 2007 Copyright Hemant Shah 15

SSH will not protect against Incorrect configuration or usage A compromised root account If you login from a host to a server and an attacker has control of root on either side, he/she can listen to your session by reading from the pseudo-terminal device, even though SSH is encrypted on the network, SSH must communicate in clear text with the terminal device Insecure home directories: if an attacker can modify files in your home directory (e.g. via NFS) he may be able to fool SSH June 26, 2007 Copyright Hemant Shah 16

Installing SSH June 26, 2007 Copyright Hemant Shah 17

Downloading Source Code You may download the source from http://www.openssh.com/ Read installation instructions to check if you have pre-requisite packages and libraries. June 26, 2007 Copyright Hemant Shah 18

Building and installing OpenSSH gtar -xzf openssh-4.5p1.tar.gz cd openssh-4.5p1./configure make make install June 26, 2007 Copyright Hemant Shah 19

Configuration files June 26, 2007 Copyright Hemant Shah 20

SSH Configuration Files SSH has two different sets of configuration files System wide configuration files User specific configuration files June 26, 2007 Copyright Hemant Shah 21

System wide configuration files The system wide configuration are stored in /etc/ssh directory ssh_config - Client configuration file. It is overridden by configuration file in user's home directory sshd_config - Configuration file for sshd server daemon ssh_host_dsa_key - The DSA private key used by the sshd daemon ssh_host_dsa_key.pub - The DSA public key used by the sshd daemon ssh_host_rsa_key - The RSA private key used by the sshd daemon for version 2 of the SSH protocol ssh_host_rsa_key.pub - The RSA public key used by the sshd for version 2 of the SSH protocol June 26, 2007 Copyright Hemant Shah 22

System wide configuration files sshd.pid - Server's PID is stored in this file June 26, 2007 Copyright Hemant Shah 23

User specific configuration files The user specific configuration files are stored in ~UserName/.ssh directory authorized_keys2 - This file holds a list of authorized public keys for users. When the client connects to a server, the server authenticates the client by checking its signed public key stored within this file id_dsa - Contains the DSA private key of the user id_dsa.pub - The DSA public key of the user id_rsa - The RSA private key of the user id_rsa.pub - The RSA public key of the user known_hosts - This file contains DSA host keys of SSH servers accessed by the user. This file is very important for ensuring that the SSH client is connecting the correct SSH server June 26, 2007 Copyright Hemant Shah 24

User specific configuration files config - Client configuration file June 26, 2007 Copyright Hemant Shah 25

Configuration files Specify authentication methods supported Specify SSH protocols supported Need to make trade-offs between security and easy-of use Behavior of the server can be controlled in following order: Compiling time configuration Configuration file Command line options June 26, 2007 Copyright Hemant Shah 26

Configuration file syntax Server configuration is stored in /etc/ssh/sshd_config file Client configuration is stored in /etc/ssh/ssh_config and ~/.ssh/config files. The file contains two types of entries Comment or blank line Key/Value pair Example: # This is a comment line Port 22 June 26, 2007 Copyright Hemant Shah 27

Server Recommendations June 26, 2007 Copyright Hemant Shah 28

Server recommendations Protocol Possible values are 1 or 2 Protocol 2 Protocol 1 has been deprecated because of vulnerabilities, it is recommended that you do not support protocol 1. June 26, 2007 Copyright Hemant Shah 29

Server recommendations Port Possible values are any integer less than 65535 Port 22 June 26, 2007 Copyright Hemant Shah 30

Server recommendations ListenAddress IP address of the system and optionally port number ListenAddress 10.90.10.101 ListenAddress 10.90.10.102:12345 By default sshd will listen to all network interfaces, if you want to limit sshd to service only certain interface then use this option. June 26, 2007 Copyright Hemant Shah 31

Server recommendations TCPKeepAlive Send TCP keepalive messages TCPKeepAlive yes If keepalive messages are not sent then server may not realize that the client has crashed. It will keep running and use resources. However, this means that connections will die if the route is down temporarily. June 26, 2007 Copyright Hemant Shah 32

Server recommendations Compression CompressionLevel Compression yes CompressionLevel 6 Not needed on intranet. June 26, 2007 Copyright Hemant Shah 33

Server recommendations IgnoreRhosts IgnoreRhosts yes June 26, 2007 Copyright Hemant Shah 34

Server recommendations UsePrivilegeSeparation UsePrivilegeSeparation yes Separates privileges by creating an unprivileged child process to deal with incoming network traffic. June 26, 2007 Copyright Hemant Shah 35

Server recommendations PermitRootLogin PermitRootLogin no Specifies whether root can login using ssh. The argument must be ``yes'', ``without-password'', ``forced-commands-only'' or ``no''. The default is ``yes''. June 26, 2007 Copyright Hemant Shah 36

Server recommendations Subsystem Subsystem sftp /usr/local/libexec/sftp-server Configures external subsystem (e.g. sftp server). June 26, 2007 Copyright Hemant Shah 37

Client Recommendations June 26, 2007 Copyright Hemant Shah 38

Client recommendations Host Host hostname or wildcard pattern. Restricts the following configuration, up to the next Host keyword, to the matching host(s). June 26, 2007 Copyright Hemant Shah 39

Client recommendations BatchMode BatchMode no If set to yes, passphrase/password querying is disabled. This option is useful in scripts and other batch jobs. June 26, 2007 Copyright Hemant Shah 40

Client recommendations ForwardX11 ForwardX11 yes June 26, 2007 Copyright Hemant Shah 41

Client recommendations ForwardX11Trusted ForwardX11Trusted yes If the this option is set to ``yes'' then remote X11 clients will have full access to the original X11 display. If this option is set to ``no'' then remote X11 clients will be considered untrusted and prevented from stealing or tampering with data belonging to trusted X11 clients. June 26, 2007 Copyright Hemant Shah 42

Client recommendations IdentityFile IdentityFile /path/to/private/key/file June 26, 2007 Copyright Hemant Shah 43

Client recommendations HostName HostName real hostname or IP address Specifies the real host name to log into. This can be used to specify nicknames or abbreviations for hosts. June 26, 2007 Copyright Hemant Shah 44

Client recommendations LocalForward LocalForward port host:port Specifies that a TCP/IP port on the local machine be forwarded over the secure channel to the specified host and port from the remote machine. June 26, 2007 Copyright Hemant Shah 45

Client recommendations Port Port port_number Specifies the port number to connect on the remote host. June 26, 2007 Copyright Hemant Shah 46

Checking configuration To check the configuration run following command: sshd -t June 26, 2007 Copyright Hemant Shah 47

Key Management June 26, 2007 Copyright Hemant Shah 48

Key pairs ssh authenticates users using key pairs private key public key June 26, 2007 Copyright Hemant Shah 49

Key management commands ssh-keygen - Create key pairs ssh-agent - Holds private key in memory ssh-add - Adds key to the key agent June 26, 2007 Copyright Hemant Shah 50

Generating key pairs shahhe@kubuntu1:~$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/shahhe/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/shahhe/.ssh/id_dsa. Your public key has been saved in /home/shahhe/.ssh/id_dsa.pub. The key fingerprint is: 99:51:ac:02:10:0c:d4:55:09:cc:86:36:cf:59:d0:33 June 26, 2007 Copyright Hemant Shah 51

Generating key pairs shahhe@kubuntu1:~$ cat ~/.ssh/id_dsa -----BEGIN DSA PRIVATE KEY----- MIIBuwIBAAKBgQDPmC7jSBnJMoQ8o6/cF4GUDP/gsCqonA0UGs2g/92N8qVTxxZg U3MgZAQ96FAsaGKFDfsxoqbp1eXX7IXUS+erPOMQnDtbooLgZN3VpvStvV/hulnn HoFJoDmoE5MnrY0Su93jZe2mPp4hOrYYQu0/8r3YRFtAzz6TCauHFxO4DQIVAJYo apgvvbg8j1raefsbreoef/ixaogbajuxbydtr0wpyz5ukt11fmvs/a34st9lfzld OjR38c9sRCf8klRZ6IuqoLUZZ3jSo56+SRsraFQReCB5GLWPx5qKzHz9xi9XFseT acb3qh70ebip3uafqntvk2k8vokc4dniexz7szxzuswbimlayxf/scvl7fmlmy9d fcmf8by2aogagedk17lrld7zfwuvyjm+26zaq/qu4yhff6cfoe1lnq/1umt6sevf SZWsj9n8fj7Ez8l03gU/g+otZXDcsS6OmNMooWkADIbkHfQ6oeoK1h/3z0hV8TY4 HnOtMZuHJMf1LPFNvINbenLS+qldGvi19aTxZUkcQJiHdpr6GR3jn9cCFE9xHd8q Y8klJEyIPYK+KQ4UrbhZ -----END DSA PRIVATE KEY----- June 26, 2007 Copyright Hemant Shah 52

Generating key pairs shahhe@kubuntu1:~$ cat ~/.ssh/id_dsa.pub ssh dss AAAAB3NzaC1kc3MAAACBAM+YLuNIGckyhDyjr9wXgZQM/+CwKqicDRQazaD/3Y3 ypvphfmbtcybkbd3oucxoyoun+zgipunv5dfshdrl56s84xcco1uigubk3dwm9k29x+g6we cegumgoagtkyetjrk73enl7ay+nie6thhc7t/yvdhew0dpppmjq4cxe7gnaaaafqcwkgqrl b24pcdawhn0guxjnn/4lwaaaiealrdvio1htcnlplqppxuwzvl9rfhjp0t/ov06nhfxz2xe J/ySVFnoi6qgtRlneNKjnr5JGytoVBF4IHkYtY/HmorMfP3GL1cWx5NoJvdCHvQRuI/e4AW qdo+tyry+golh00grdntjldlsxyeiytphd/+xy8vt8yuzl118ix/whlyaaacagedk17lrld 7zfWUVyJm+26ZaQ/QU4Yhff6Cfoe1lnq/1UmT6SEVfSZWsj9n8fj7Ez8l03gU/g+otZXDcs S6OmNMooWkADIbkHfQ6oeoK1h/3z0hV8TY4HnOtMZuHJMf1LPFNvINbenLS+qldGvi19aTx ZUkcQJiHdpr6GR3jn9c= shahhe@kubuntu1 June 26, 2007 Copyright Hemant Shah 53

Executing commands June 26, 2007 Copyright Hemant Shah 54

Logging into remote system shahhe@kubuntu1:~$ ssh shah@xnet.com Last login: Mon Jun 18 21:26:33 2007 from d47-69-253-190. * Problems? Questions? Email: help@xnet.com * Type "whatsup" to see information posted to our "What's Up?" page. You have mail. You have 17 read messages. You have no new mail. /home/customer/shah {shah@typhoon} 1> June 26, 2007 Copyright Hemant Shah 55

Copying file to remote system shahhe@kubuntu1:~$ scp.profile shah@xnet.com:tmp/profile.kubuntu.profile 100% 566 0.6KB/s 00:00 shahhe@kubuntu1:~$ scp shah@xnet.com:tmp/profile.kubuntu tmp/. profile.kubuntu 100% 566 0.6KB/s 00:00 June 26, 2007 Copyright Hemant Shah 56

Executing commands on remote system shahhe@kubuntu1:~$ ssh shah@xnet.com ls Mail News bin mail public_html tmp June 26, 2007 Copyright Hemant Shah 57

Executing commands on remote system shahhe@kubuntu1:~$ ssh -Y shah@xnet.com /opt/sfw/bin/xterm June 26, 2007 Copyright Hemant Shah 58

Force execution of command June 26, 2007 Copyright Hemant Shah 59

Force execution of command To force an execution of a command use command keyword in authorized_key2 file. command="~/bin/dumpempnames",no-port-forwarding ssh-dss AAAAB3NzaC1kc3MAAACBAIB8B1MvYlWnVeyPE6bMwrTr1OM8O2HXiQQKq9801q fmof9x3qyzzxvfegdnydtn4o1sr6t7bmcnvotc7szoglafibfqohfmiexabvyz xin/2d2juof7yu53zrx1bjhkzqqpcj6jx7fxjpqlld0bvl9r3qopipj6jt0yvy Ae4Zj9AAAAFQDoejxCMgfZ0O/Zxwxn3mFidTpogQAAAIBDQvrhRsDFhA1UUkBO 203pVujfnNYF7X58mD/WPGZ+Z4aR8dGuD21X7hC6M8ko9a9wLLYigELSkUiWps VZ/NJyBxhrCCD3YCNXeltJ7L0KaWGP96H2KkDtYsP7RMhAmztVpmlOrPzXbIpU 3jpq8dRJqUksG8mq2dbXPBWgh9xHyQAAAIBG9iwGfjPLDTH1niXk5tbZQUuEGk GZzCaBw8jJlKPXMWeE7rVmBXV5sC/zhcX3OAXUNj8OUpafxFZxbxtmnzIgnehW duwtwmiqpoi2f8ov9fculpfnywgnn4v4hmqdlscwnoie3obv05wterdyjay8bv 2Zfh9EJGEJvFFerdur/g== Key for Dumping active user names. June 26, 2007 Copyright Hemant Shah 60

Force execution of command Execute command as follows: ssh -i ~/keys/dumpempnames.dsa user@remotehost June 26, 2007 Copyright Hemant Shah 61

Options for authorized_keys2 file Option command="command name" environment="variable=value" from="host or ip address" no-agent-forwarding no-port-forwarding no-pty no-x11-forwarding Meaning Specify a force command Set environment variable Limit incoming hosts Disable forwarding agent Disable port forwarding Do not allocate TTY Disable X11 forwarding June 26, 2007 Copyright Hemant Shah 62

Port forwarding June 26, 2007 Copyright Hemant Shah 63

Port forwarding Client App Insecure Server App ssh client Secure ssh server June 26, 2007 Copyright Hemant Shah 64

Port forwarding Create SSH tunnel ssh -f -N -L10112:localhost:80 www.example.com Add to ~/.ssh/config file and run ssh command Host webtunnel User shahhe Hostname www.example.com LocalForward 10112 www.example.com:80 ssh -f -N webtunnel June 26, 2007 Copyright Hemant Shah 65

Port forwarding Start application using port on localhost firefox http://localhost:10112 June 26, 2007 Copyright Hemant Shah 66

Agent forwarding June 26, 2007 Copyright Hemant Shah 67

Agent forwarding You want to login to the computer at work from your home computer or from from hotel while traveling. The computer at work is behind the firewall so you cannot connect to it directly. You are allowed to connect to a bastion host, but are not allowed to store private keys on it. What can you do? June 26, 2007 Copyright Hemant Shah 68

Agent Forwarding Home Bastion Work ssh sshd (proxy agent) Login ssh ssh sshd ssh June 26, 2007 Copyright Hemant Shah 69

sshd configuration on bastion host Port 46464 Protocol 2 PasswordAuthentication no X11Forwarding yes Compression no Subsystem sftp /usr/libexec/sftp-server June 26, 2007 Copyright Hemant Shah 70

ssh tunnel configuration on home system The configuration is stored in ~/.ssh/tunnel.cfg file. Host * ForwardX11 yes ForwardAgent yes NoHostAuthenticationForLocalhost yes Host bastionhost User RemoteUser IdentityFile /home/localuser/.ssh/work_dsa HostName 69.2.50.60 Port 46464 June 26, 2007 Copyright Hemant Shah 71

ssh client configuration on home system Host * ForwardX11 yes ForwardAgent yes NoHostAuthenticationForLocalhost yes Host portmap HostName localhost LocalForward 10001 10.60.80.101:22 LocalForward 10002 10.60.80.102:22 Host host1 User RemoteUser IdentityFile /home/localuser/.ssh/work_dsa HostName localhost Port 10001 Host host2 User RemoteUser IdentityFile /home/localuser/.ssh/work_dsa HostName localhost Port 10002 June 26, 2007 Copyright Hemant Shah 72

Setting Key Pair Generate key with password Store private key on Home system Store public key on Bastion host Store public key on Work system June 26, 2007 Copyright Hemant Shah 73

Login into work systems Do the following on the HOME system: Start ssh-agent and add the key ssh-agent $SHELL ssh-add ~/.ssh/work_dsa Create tunnel to bastion host ssh -f -N -F ~/.ssh/tunnel.cfg bastionhost ssh -f -N UserName@portmap Login in to work systems ssh host1 ssh host2 June 26, 2007 Copyright Hemant Shah 74

Environment variables June 26, 2007 Copyright Hemant Shah 75

Environment variables Variable Meaning Example SSH_CONNECTION Client and server socket information 10.90.10.107 45756 10.90.10.182 22 SSH_AUTH_SOCK Path to socket /tmp/ssh-fcrci22249/agent.22249 SSH_CLIENT Client socket information 10.90.10.107 45756 22 SSH_TTY Name of TTY /dev/pts/48 June 26, 2007 Copyright Hemant Shah 76

Other ssh based applications June 26, 2007 Copyright Hemant Shah 77

Other ssh based applications sshfs - ssh based file system client http://fuse.sourceforge.net/sshfs.html sftp - secure file transfer. Part of OpenSSH http://www.openssh.com/ June 26, 2007 Copyright Hemant Shah 78

OpenSSH alternatives for windows PuTTY TTSSH Cygwin MSSH WinSCP FileZilla June 26, 2007 Copyright Hemant Shah 79

Advantages of using ssh June 26, 2007 Copyright Hemant Shah 80

Advantages Proven technology Strong encryption Both free and commercial versions exist Runs on many platforms Tunneling of ports works well and can be used for simple VPNs Many authentication methods supported Can be SOCKS5 proxy aware Use it instead of VPN June 26, 2007 Copyright Hemant Shah 81

Disadvantages of using ssh June 26, 2007 Copyright Hemant Shah 82

Disadvantages Port ranges & dynamic ports can't be forwarded SSH server daemon: Cannot restrict what ports may or may not be forwarded, per user When a user is authenticated by password, the client's RSA identity is not verified (against ssh_known_hosts). The verification only takes place when.[sr]hosts trust is used Port forwarding can also introduce security problems. The SSH server doesn't allow detailed configuration of what forwarding is allowed from what client to what server etc. A client on the Internet that uses SSH to access the Intranet, can expose the Intranet by port forwarding June 26, 2007 Copyright Hemant Shah 83

Resources http://www.openssh.com/ http://fuse.sourceforge.net/sshfs.html Barrett, D., Silverman, R., & Byrnes, R. (2005). SSH The Definitive Guide, Second Edition. O'Reilly Media, Inc. SSH FAQ http://www.employees.org/~satch/ssh/faq/ssh-faq.html June 26, 2007 Copyright Hemant Shah 84