Secure Shell (SSH) at SLAC |
UNIX
at SLAC
Security |
||
| Updated: 13 April 2010 |
ContentsSecure Shell at SLACUsing SSH Between UNIX machines at SLAC Connecting from OffSite Problems and workarounds Reference Secure Shell at SLACSLAC uses OPENssh software on all unix machines. Where possible we use the vendor supplied version, but for older machines, we use a locally compiled version. Since most SLAC home directories are in AFS, using ssh keys won't work well. We use GSSAPI authentication ( i.e. kerberos 5) and credential forwarding to allow the ssh daemon then runs a special command when you login to obtain an AFS token for you.Advantages of OPENssh.
Protocols in use at SLACThere are two different SSH protocols, but only Protocol 2 supports GSSAPI login and forwarding of kerberos 5 credentials. Due to a DOE mandate SSH V1 has been turned off at SLAC as of January 2008. SSH V1 is largely deprecated and all recent ssh clients should support V2. The SFTP client and server are also installed at SLAC. The OpenSSH SFTP client uses SSH Protocol 2 by default. Using SSHBetween UNIX machines at SLACSSH can be used either to initiate login sessions or copy files using scp. All taylored machines at SLAC automatically have their ssh host keys updated in the global known_hosts file every night. If you are at SLAC and see the warning about "unknown host key" when connecting to a SLAC machine, please contact unix-admin@slac.stanford.eduNote: The latest version of ssh requires that you have a K5 kerberos ticket to use these commands without repeatedly typing your password. Most machines at SLAC have been setup to obtain a K5 ticket automatically when you first login, however you can always check if you have a ticket using the klist command. If you don't have a valid ticket use kinit to obtain one.
SSH tries several methods of authentication in sequence, and which one succeeds depends on your setup. The following sections describe the methods in the order that ssh attempts them.
Between a SLAC machine and a non-SLAC machineThis case works much the same way as between SLAC machines, except that you have to concern yourself a bit with host keys, which are managed automatically for you on SLAC machines. Each host has a private key and a public key. In this explanation, we will call the host you are connecting from the client machine, and the host you are connecting to the servermachine. When you first connect to a server that ssh on your client does not know about, it will ask whether you want to accept the public key of that machine. It will store that key in a file in your home directory on your client named ~/.ssh/known_hosts. Every connection after that will check the public key of the server, and will give you loud warnings if it is ever different. This protects you from hacker attacks in which another machine impersonates the trusted server machine to which you are trying to connect. The dialog looks like this: > ssh flora.slac.stanford.edu Host key not found from the list of known hosts. Are you sure you want to continue connecting (yes/no)? yes Host 'flora.slac.stanford.edu' added to the list of known hosts. If you get the wrong key from the remote host, you get this dialog: > ssh flora.slac.stanford.edu @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the host key has just been changed. Please contact your system administrator. Add correct host key in /u/sf/boeheim/.ssh/known_hosts to get rid of this message. Agent forwarding is disabled to avoid attacks by corrupted servers. X11 forwarding is disabled to avoid attacks by corrupted servers. Are you sure you want to continue connecting (yes/no)? No In fact, you will often get exactly this warning if you connect to pooled machines such as rhel5-64, flora, or noric, since you will get different machines each time, with different host keys. The simplest solution to this is to obtain the host keys of all the machines in the pool from SLAC with this command, run from the client machine. These keys are available via anonymous ftp from the server ftp.slac.stanford.edu, in the directory /admin/: ftp://ftp.slac.stanford.edu/admin/known_hostsCopy this file to your client machine and merge it into your ~/.ssh/known_hosts there, replacing any existing keys for the corresponding SLAC hosts. From time to time you may need to repeat this process, for example, when SCS adds new machines to any of the pools. When connecting from a client machine at SLAC to a remote server at
another site, you will get a similar dialog. In this case you will be saving
the public keys of the servers that you connect to in the file ~/.ssh/known_hosts
in your home directory at SLAC.
OpenSSH and Changed Host Keys Note that OpenSSH will not permit password authentication if the remote host's public key has changed. On the other hand, if a user is authenticating via an RSA key, there is no problem connecting to a host with a changed host key, so long as "StrictHostKeyChecking no" is set in the system-wide ssh_config file, or used on the command line via the -o option, or set in the user's personal ~/.ssh/config file. For example: ksa@osiris $ ssh elaine.stanford.edu @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: POSSIBLE DNS SPOOFING DETECTED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ The RSA1 host key for elaine.stanford.edu has changed, and the key for the according IP address 171.64.15.106 is unknown. This could either mean that DNS SPOOFING is happening or the IP address for the host and its host key have changed at the same time. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA1 host key has just been changed. The fingerprint for the RSA1 key sent by the remote host is 26:b7:69:94:1b:4e:65:7c:6d:4a:11:ed:ed:fd:04:77. Please contact your system administrator. Add correct host key in /u/sf/ksa/.ssh/known_hosts to get rid of this message. Offending key in /u/sf/ksa/.ssh/known_hosts:1 Password authentication is disabled to avoid trojan horses. Agent forwarding is disabled to avoid trojan horses. X11 forwarding is disabled to avoid trojan horses. Permission denied. Exit 255. So, to still be able to connect to a host with a changed host key using an OpenSSH client, users will have to:
In the above example, elaine.stanford.edu is a pool of hosts (much like noric, flora, and tersk at SLAC). Therefore, the correct thing to do is put all the host keys for the elaine pool in the user's ~/.ssh/known_hosts file. If the bad host key is in the system's global known_hosts file, then the user needs to put the good host key in his/her personal known_hosts file, which gets searched first. Note that the option 'StrictHostKeyChecking ask' means the user will get prompted before connecting to a new, previously unknown host. Connecting w/o a Password from Remote SitesThis requires an ssh client that is capable of using GSSAPI authentication with kerberos 5 and forwarding the credentials. Fortunately most of the major Linux versions come with this capability and all recent versions of OS X also come with this software as part of the default installation. For more details on how to set this up see Using GSSAPI authentication. Connecting from a PCThere are commercial and open source clients available for Windows PCs. Secure CRT is an excellent choice, but is not free. If you have a sunetid (i.e. SLAC employee), you can get it for free from the Essential Stanford Software distribution.In Mac OS X, the open source OpenSSH client is included with the basic OS install, it also includes the klist and kinit commands used above. Forwarding other services with sshSSH can forward other TCP services over the encrypted connection. Examples of such services would be FTP, POP, IMAP, and X-Windows. This keeps the passwords that these services forward over the network from being visible to hackers who may be watching the network traffic. These services have no encryption of their own built in, and need the protection of an external protocol. This forwarding is often referred to as tunneling, because the TCP traffic is sent through an encrypted tunnel that shields it from view.The forwarding of X-Windows traffic is automatic with ssh, unless you explicitly disable it. To start up an X command on a remote host, start it with an ssh command like this: ssh -f outpost.podunk.edu xtermThis will start an ssh session, which will direct the traffic to and from the xterm along the encrypted tunnel. X Magic Cookie authentication is automatically handled for you. This method is the only secure way of opening an X session across SLAC's firewall, which blocks incoming X traffic (incoming is when the display screen is at SLAC and the program is running offsite). FTP is more difficult to forward, since an FTP session is made up of two connections, one from the client to the server to send the login information, password, and command, and another from the server back to the client to transfer the data. It has proven difficult to give a formula for making this work with arbitrary FTP clients, as most common clients and servers have added protections against hackers redirecting sessions to unintended destinations. Your best bet for transferring data between machines is the scp command. If you must use FTP, first see if you can use anonymous FTP servers for making data available and anonymous FTP drop-boxes for transferring data in. If you have to use authenticated FTP (with a username and password), you can try using ssh to forward port 21 to encrypt only the control channel, or you can see if your client and server support passive mode transfers.
Problems and work-arounds
Here are some current problems you might encounter when using SSH at SLAC,
along with suggested work-arounds.
|