<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_ssh_dir(config, username):
 """Get the users ssh dir"""

    sshdir = config.get('ssh_config_dir')
    if not sshdir:
        sshdir = os.path.expanduser('~/.ssh')
        if not os.path.isdir(sshdir):
            pwentry = getpwnam(username)
            sshdir = os.path.join(pwentry.pw_dir, '.ssh')
            if not os.path.isdir(sshdir):
                sshdir = None
    return sshdir