Securing ssh

Posted on 2004-11-11
Last Modified: 2010-04-22
I administer a system where the only way to login between trusted hosts is via ssh. This is fine apart from it is possible to set up id key files in the user's .ssh directory that get used on a challenge response basis so that if the machines at both ends have the same key files, the user can log in without typing in a password.

Is there anyway to stop this from a system's point of view? I have had a look in /etc/ssh/sshd_config but there doesn't seem to be anything that relates to this precise scenario.

The reason why I want to do this is so that I can share out home directories to a few `semi-trusted' hosts without a user on that system assuming t he identity of another user, getting a hold of their id files and then obtaining access to the other systems as that user. Telnet and rsh/rlogin et al have all been disabled.


Question by:aecooper
    LVL 36

    Expert Comment

    Hi aecooper,
    There are a few lines in the file you mentioned related to this authentication type:-

    Have a look in the manual page to find out which one you wish to disable.
    LVL 36

    Expert Comment

    RSAAuthentication is for SSH V1 only
    PubkeyAuthentication is for SSH V2 only

    Therefore I would tyr setting both to no.
    LVL 51

    Expert Comment

    and to complete grblades suggestion, disable also:

    LVL 38

    Expert Comment


       In sshd_config, you can simply rename
    AuthorizedKeysFile     .ssh/authorized_keys  ===> .ssh/xxx

       Then the user can not login without passwd and it safe since sshd_config has permission 600.

    LVL 1

    Expert Comment

    Actually, the keys that you are mentioning are a public/private key pair.  They are not the same key.  Every user should have their own, private ".ssh/authorized_keys" file.  I think that the permissions are 600 so other users would not be able to modify it and add their public key.  Since the users' private keys are not your server their should be no problem.  
    LVL 23

    Accepted Solution

    If you share out home directories like this, I believe that .ssh  directories is just one of many
    possible problems... what about .login and .profile files?

    Executed when a user logs in..
    Programs setuid as the user etc...

    I think there are many possible ways this setup would allow one user to execute code as a
    different user.

    Without major reworking of the shell, login process, and configuration of user programs, the
    ability to write to a user's home directory is basically equivalent to the ability to pose as them.

    You've managed to make challenge based auth seem a problem, but in general, it's much better than password authentication for remote access purposes
    . (Passwords can be guessed, a lot more easily than huge secret keys can be)

    LVL 1

    Expert Comment

    The person never chose an answer, I guess this is yet another abandoned post by someone who wanted help, but would not help in return by granting points.
    LVL 1

    Author Comment

    No, this is not the case. The first three comments refer to undocumented features not mentioned in the ssh documentation on our system. The last comment was sort of admitting defeat in as much as there is no way of doing what I want and so the only safe thing to do is to disable write access to home directories.

    I gave high points to this questions because I wanted a quick solution. But on not finding one I had to do more research into the problem and reluctantly came to the same conclusion.
    LVL 23

    Expert Comment

    The options are part of OpenSSH's  sshd_config

    PubkeyAuthentication and RSAAuthentication  options
    turn on or off those authentication methods.

    And   HostbasedAuthentication   controls  .rhosts style authentication

    Anyway,   the authorized_keys file could be rendered useless by using
    the   'AuthorizedKeysFile'  option in sshd_config on every system, to use
    the same file for all users on the machine   (not found in their home directory),
    so the SSH problem should be surmountable.

    The major problem with a shared directory is user login scripts and preferences
    files..  one user might edit another's mail client  config file and include a
    command to be run as them, next time they read their mail

    In this respect, it would probably be more sound to just create a shared
    subdirectory for each user, and place a line in the .login   or .profile to
    set HOME to that subdirectory and CD into it.

    LVL 1

    Author Comment

    Many thanks for the update... :-) I'll have a look into it. Many thanks once again.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Hello EE, Today we will learn how to send all your network traffic through Tor which is useful to get around censorship and being tracked all together to a certain degree. This article assumes you will be using Linux, have a minimal knowledge of …
    BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (, affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now