Skip to content

The way of resolving user's home directory is not reliable #20

@hurngchunlee

Description

@hurngchunlee

sshDir := path.Join(homeDir, groupname, username, ".ssh")

The code above is how the .ssh/authorized_keys path is constructed. It assumes that the user's home directory follows the format of /home/{group_name}/{user_name} which is not always the case. It should be replaced by

import "os/user"
...
u, _ := user.Lookup(usename)
sshDir := path.Join(u.HomeDir, ".ssh")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions