![]() | ![]() |
Kerberos (SSH1 and OpenSSH/1 only)
If this still doesn't work, check your local client configuration file (~/.ssh/config or ~/.ssh2/ssh2_config) to make sure you haven't accidentally set the wrong value for the User keyword. In particular, if your configuration file contains Host values with wildcards, check that your current command line (the one that isn't working) isn't matching the wrong section in the file. [Section 7.1.3.4, "Multiple matches"] One common problem on the server side involves OpenSSH and Pluggable Authentication Modules configuration. PAM is a general system for performing authentication, authorization, and accounting in an application-independent fashion. If your operating system supports PAM (as Linux and HPUX do, for example), OpenSSH will probably have been automatically compiled to use it. Unless you take the extra step of configuring PAM to support SSH, all password authentication will mysteriously fail. This is usually just a matter of copying the appropriate sshd.pam file from the contrib directory in the OpenSSH distribution, naming the copy "sshd" and placing it in the PAM configuration directory (usually /etc/pam.d ). The contrib directory contains several example files for different flavors of Unix. For example, on a RedHat Linux system:$ ssh -l my_remote_username server.example.com $ scp myfile my_remote_username@server.example.com:
If OpenSSH isn't using PAM, and password authentication still isn't working, the compilation switches -- with-md5-passwords or -- without-shadow might be relevant. These make no difference if PAM support is enabled in OpenSSH, because they deal with how OpenSSH reads the Unix passwd map. When using PAM, the OpenSSH code doesn't read the passwd map directly; the PAM libraries do it instead. Without PAM, though, if your system is using MD5-hashed passwords instead of the more traditional crypt (DES) hash, you must use -- with-md5-passwords. You can tell which hash your system is using by inspecting the /etc/passwd and /etc/shadow files. The hashed password is the second field in each entry; if the password field in /etc/passwd is just "x", then the real entry is in /etc/shadow instead. MD5 hashes are much longer and contain a wider range of characters:# cp contrib/redhat/sshd.pam /etc/pam.d/sshd # chown root.root /etc/pam.d/sshd # chmod 644 /etc/pam.d/sshd
Finally, you can try -- without-shadow if you suspect OpenSSH is trying to use the shadow password file, but your system doesn't use it.# /etc/shadow, MD5 hash test:$1$tEMXcnZB$rDEZbQXJzUz4g2J4qYkRh.:... # /etc/shadow, crypt hash test:JGQfZ8DeroV22:...
earth 1024 37 71641647885140363140390131934...
earth,gaia,terra 1024 37 71641647885140363140390131934...
$ ssh -l jones server.example.com
In your server account, make sure that the following files and directories are owned by you and aren't world writable: ~, ~/.ssh, ~/.ssh/authorized_keys, ~/.ssh2, ~/.rhosts, and ~/.shosts.$ ssh -v server.example.com ... server.example.com: Remote: Bad file modes for /u/smith/.ssh
check that my-identity is an identification file, not a private key file. (In contrast, ssh -i for SSH1 and OpenSSH expects a private key file.) Remember that SSH2 identification files are text files containing the names of private keys.$ ssh2 -i my-identity server.example.com
and you know you're typing your passphrase correctly, then first make sure you're typing your PGP passphrase correctly. (For instance, encrypt a file with that public key and decrypt it.) If so, then there might be an incompatibility between the PGP implementations on your client and server machines. We've seen this behavior when the PGP key (generated on the client machine) doesn't have sufficient bits for the PGP implementation on the server machine. Generate a new key on the server machine.Passphrase for pgp key "mykey": ******** smith's password:
# SSH1, OpenSSH $ ssh-keygen -N '' -b 1024 -f /etc/ssh_host_key # SSH2 only $ ssh-keygen2 -P -b 1024 /etc/ssh2/hostkey
If not, you need to run an agent before ssh-add will work.$ /usr/bin/ps -ef | grep ssh-agent smith 22719 1 0 23:34:44 ? 0:00 ssh-agent
If not, then you probably ran ssh-agent incorrectly, like this:$ env | grep SSH SSH_AUTH_SOCK=/tmp/ssh-barrett/ssh-22719-agent SSH_AGENT_PID=22720
For the single-shell method, you must use eval with backquotes:# Wrong! $ ssh-agent
Or for the subshell method, you must instruct ssh-agent to invoke a shell:$ eval `ssh-agent`
$ ssh-agent $SHELL
If not, your SSH_AUTH_SOCK variable might be pointing to an old socket from a previous invocation of ssh-agent, due to user error. Terminate and restart the agent properly.$ ls -lF $SSH_AUTH_SOCK prwx -- -- -- 1 smith 0 May 14 23:37 /tmp/ssh-smith/ssh-22719-agent|
# correct no-x11-forwarding,no-pty 1024 35 8697511247987525784866526224505... # INCORRECT (will silently fail) no-x11-forwarding no-pty 1024 35 8697511247987525784866526224505... # ALSO INCORRECT (note the extra space after "no-x11-forwarding,") no-x11-forwarding, no-pty 1024 35 8697511247987525784866526224505...
You intend that the username for logging into server.example.com is "linda", and the default username for hosts not explicitly listed earlier is "smith". However, the line "User smith" is still inside the "Host server.example.com" block. And since there's an earlier User statement for server.example.com, "User smith" doesn't ever match anything, and ssh appears to ignore it. The right thing to do is this:# last Host block Host server.example.com User linda # defaults User smith
# last Host block Host server.example.com User linda # defaults Host * User smith
The -f flag makes sense only when you give ssh1 a command to run after it goes into the background:# This is wrong $ ssh1 -f server.example.com
If you just want the SSH session for port-forwarding purposes, you may not want to give a command. You have to give one anyway; the SSH1 protocol requires it. Use sleep 100000. Don't use an infinite loop like the shell command while true; do false; done. This gives you the same effect, but your remote shell will eat all the spare CPU time on the remote machine, annoying the sysadmin and shortening your account's life expectancy.$ ssh1 -f server.example.com /bin/who
The latest versions of SSH2 have a new server configuration statement, AllowCshrcSourcingWithSubsystems, which should be set to no to prevent this problem.if ($?prompt) then echo 'Here is the message that screws up scp.' endif
the local shell attempts to find local files matching the pattern server.example.com:a*. This is probably not what you intended. You probably wanted files matching a* on server.example.com to be copied to the local machine. Some shells, notably C shell and its derivatives, simply report "No match" and exit. Bourne shell and its derivatives (sh, ksh, bash), finding no match, will actually pass the string server.example.com:a* to the server as you'd hoped. Similarly, if you want to copy your remote mail file to the local machine, the command:$ scp server.example.com:a* .
might not do what you intend. $MAIL is expanded locally before scp executes. Unless (by coincidence) $MAIL is the same on the local and remote machines, the command won't behave as expected. Don't rely on shell quirks and coincidences to get your work done. Instead, escape your wildcards and variables so the local shell won't attempt to expand them:$ scp server.example.com:$MAIL .
See also Appendix A, "SSH2 Manpage for sshregex" for specifics on scp2 's regular expressions.$ scp server.example.com:a\* . $ scp 'server.example.com:$MAIL' .
but if you forget the final colon:$ scp myfile server.example.com:
myfile gets copied locally to a file called "server.example.com". Check for such a file on the local machine.# This is wrong! $ scp myfile server.example.com
Oops, your friend has just replaced your authorized_keys file, giving himself full login permissions. Maybe you can accomplish what you want with a clever forced command, limiting the set of programs your friend may run in your account. [Section 8.2.4.3, "Displaying a command menu "]$ scp evil_authorized_keys you@your.host:.ssh/authorized_keys
# tar cpf - local_dir | (ssh remote_machine "cd remote_dir; tar xpf -")
Satisfied, you try scp2 and get this:$ /usr/local/f-secure/bin/ssh2 -v -c cast server ... debug: c_to_s: cipher cast128-cbc, mac hmac-sha1, compression none debug: s_to_c: cipher cast128-cbc, mac hmac-sha1, compression none
scp2 is running the wrong copy of ssh2 from /usr/local/bin/ssh2, rather than /usr/local/f-secure/bin/ssh2. To fix this, simply put /usr/local/f-secure/bin earlier in your PATH than /usr/local/bin, or specify the alternative location of ssh2 with scp2 -S. The same problem can occur in other situations where SSH programs run other ones. We have run afoul of it using hostbased authentication with both 2.1.0 and 2.2.0 installed. The later ssh2 ran the earlier ssh-signer2 program, and the client/signer protocol had changed, causing it to hang.$ /usr/local/f-secure/bin/scp2 -c cast foo server:bar FATAL: ssh2: Cipher cast is not supported. Connection lost.
Your FTP client probably needs to run in passive mode (execute the passive command). FTP data connections carry the files being transferred. These connections occur on randomly selected TCP ports and can't be forwarded in general, unless you enjoy pain. If firewalls or NAT (network address translation) are involved, you may need additional steps (or it may not be possible).$ ssh -L2001:name.of.server.com:21 name.of.server.com $ ftp localhost 2001
Some flavors of Unix actually have code in the standard shell startup files (e.g., /etc/bashrc, /etc/csh.login) that unconditionally sets XAUTHORITY to ~/.Xauthority. If that's the problem, you must ask the sysadmin to fix it; the startup file should set XAUTHORITY only if the variable is unset.$ echo $XAUTHORITY /tmp/ssh-maPK4047/cookies
![]() | ![]() | ![]() |
12. Troubleshooting and FAQ | ![]() | 12.3. Other SSH Resources |
Copyright © 2002 O'Reilly & Associates. All rights reserved.