2

I'm using OpenSSH from a Windows machine to connect to a Linux Mint 9 box. My Windows user name doesn't match the ssh target's user name, so I'm trying to specify the user to use for login using ssh_config. I know OpenSSH can see the ssh_config file since I'm specifying the identify file in it.

The section specific to the host in ssh_config is:

  Host hostname
    HostName      hostname
    IdentityFile  ~/.ssh/id_dsa
    User          username
    Compression   yes

If I do ssh username@hostname it works.

Trying using ssh_config only gives:

F:\>ssh -v hostname
OpenSSH_5.6p1, OpenSSL 0.9.8o 01 Jun 2010
debug1: Connecting to hostname [XX.XX.XX.XX] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /cygdrive/f/progs/OpenSSH/home/.ssh/id_rsa type -1
debug1: identity file /cygdrive/f/progs/OpenSSH/home/.ssh/id_rsa-cert type -1
debug1: identity file /cygdrive/f/progs/OpenSSH/home/.ssh/id_dsa type 2
debug1: identity file /cygdrive/f/progs/OpenSSH/home/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1 Debia
n-3ubuntu5
debug1: match: OpenSSH_5.3p1 Debian-3ubuntu5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'hostname' is known and matches the RSA host key.
debug1: Found key in /cygdrive/f/progs/OpenSSH/home/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /cygdrive/f/progs/OpenSSH/home/.ssh/id_rsa
debug1: Offering DSA public key: /cygdrive/f/progs/OpenSSH/home/.ssh/id_dsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

I was under the impression that (as outlined in this question: How to make ssh log in as the right user?) specifying User username in ssh_config should work.

Why isn't OpenSSH using the username specified in ssh_config?

6
  • No, it does not see the configuration. Notice how ssh is trying id_rsa before id_dsa - meaning it is using the default identity files, not the one you pointed to. Feb 2, 2011 at 16:18
  • Where is your ssh_config file located? Feb 2, 2011 at 16:19
  • True. I hadn't noticed that. The ssh_config would be /cygdrive/f/progs/OpenSSH/etc/ssh_config as far as ssh is concerned. Feb 2, 2011 at 16:27
  • Copying ssh_config from there to /cygdrive/f/progs/OpenSSH/home/.ssh/config fixed it. The question now is what do I do with this question now that it's been shown to be based on incorrect assumptions? Does it make sense to modify this question into "Why isn't OpenSSH using my config file?" and have an answer about how it wasn't in the right place? Or should I look at deleting the question? Feb 2, 2011 at 16:30
  • @Jordan: I think the usual procedure is to post your findings and the solution as an answer, then accept it. You can check meta for more information. Feb 2, 2011 at 16:34

3 Answers 3

4

The problem is actually that OpenSSH is looking for the configuration at ~/.ssh/config (which expands to /cygdrive/f/progs/OpenSSH/home/.ssh/config) and not at /cygdrive/f/progs/OpenSSH/etc/ssh_config.

Place the settings in ~/.ssh/config instead.

1

For anyone who comes across this, and is trapped on windows, the windows equiv in cygwin for the location of your .ssh folder is not the $HOME directory you specified in your env! The path that cygwin openssh uses is /home/username/.ssh :(

My fix was to remove the /home/username directory and instead symlink it to the real home dir (the directory that "cd ~" switches to). Good luck.

0

Typically, custom user configurations should go in ~/.ssh/config and not in /etc/ssh/config. /etc/ssh/config is for system-wide changes.

1
  • 1
    ssh_config is not related to the sshd daemon (which uses sshd_config). Feb 2, 2011 at 16:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .