Results 1 to 5 of 5

Thread: SSH config

  1. #1

    Default SSH config

    I'm using ~/.ssh/config to ssh to various hosts. I'm using the shortcut hostname when I ssh to a host, eg. "ssh rekon" would log me in to the host rekon.

    I have a different user name that is not in the global settings but is defined in the local setting for that particular host. If I ssh to that host, I still get the global user name. How can I change this?

    My ~/.ssh/config

    Code:
    # Site-wide defaults for some commonly used default options
    
    Host *
       ForwardX11 yes
       ForwardX11Trusted yes
       ForwardAgent yes
       ForwardX11 yes
       Protocol 2
       Port 22
       User chris
       IdentityFile /home/chris/ssh_keys/chris_ssh_keys
       Compression yes
    
       Host weldpond
       HostName ssh1.company.tld
    
       Host rekon
       User ben
       HostName ssh2.company.tld.

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: SSH config

    Which one is it in your config?

  3. #3

    Default Re: SSH config

    Quote Originally Posted by ken_yap View Post
    Which one is it in your config?
    user ben (ssh to server rekon should use user ben but it uses user chris instead)

    Thanks.

  4. #4
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: SSH config

    You can trace what ssh is doing with your config file by using -v. For example, ssh -v rekon should give you:

    ...
    debug1: Applying options for rekon
    debug1: Applying options for *
    ...

    in the first few lines. If it doesn't mention rekon, your file is faulty. Check these things: that you have ended the file with a newline. Add an extra blank line to be sure. Also that there is no junk after rekon, e.g. a carriage return introduced by a DOS editor. Also I don't know if it matters, but it would be good practice to make the Host lines flush left. Makes it easier to see where the Hosts are too. And normally I put the global section at the bottom but I don't think this matters.

    The other thing I noticed is that you have specified an Identify file in the globals. Remember anything in the globals that isn't overridden is appended to the specific config. So you would be using chris's key for login instead of a password for User ben. You may have to specify that the host rekon uses passwords and not public key login.

    Host weldpond
    ...

    Host rekon
    ...

    Host *
    ...

    and so on.

  5. #5

    Default Re: SSH config

    Quote Originally Posted by ken_yap View Post
    You can trace what ssh is doing with your config file by using -v. For example, ssh -v rekon should give you:

    ...
    debug1: Applying options for rekon
    debug1: Applying options for *
    ...

    in the first few lines. If it doesn't mention rekon, your file is faulty. Check these things: that you have ended the file with a newline. Add an extra blank line to be sure. Also that there is no junk after rekon, e.g. a carriage return introduced by a DOS editor. Also I don't know if it matters, but it would be good practice to make the Host lines flush left. Makes it easier to see where the Hosts are too. And normally I put the global section at the bottom but I don't think this matters.

    The other thing I noticed is that you have specified an Identify file in the globals. Remember anything in the globals that isn't overridden is appended to the specific config. So you would be using chris's key for login instead of a password for User ben. You may have to specify that the host rekon uses passwords and not public key login.

    Host weldpond
    ...

    Host rekon
    ...

    Host *
    ...

    and so on.
    Thanks! I have put "Host *" at the bottom of the file and it's now working!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •