Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: add GetHostUser for u@host and .ssh/config #280

Merged
merged 1 commit into from
Jul 14, 2024

Conversation

rminnich
Copy link
Member

Since 2017 cpu used $USER as the user. Now that it supports ssh, it needs better processing.

Add GetHostUser, which takes a string in [user@]host form, and returns a host and user name as follows:
if user@host form, return the host and user.

Look up the host in .ssh/config; if found, and
there is a UserName record, return that UserName

Otherwise return host and $USER.

If a host entry is found in .ssh/config, the
HostName from that entry is used.

This means that code that used GetHost should start using GetHostUser.

@rminnich rminnich requested review from ericvh, brho and Lencerf July 12, 2024 21:11
@rminnich rminnich force-pushed the host@user branch 2 times, most recently from 3d8bcaf to 7132caa Compare July 12, 2024 21:41
client/fns.go Outdated Show resolved Hide resolved
Since 2017 cpu used $USER as the user. Now that it supports
ssh, it needs better processing.

Add GetHostUser, which takes a string in [user@]host form,
and returns a host and user name as follows:
if user@host form, return the host and user.

Look up the host in .ssh/config; if found, and
there is a UserName record, return that UserName

Otherwise return host and $USER.

If a host entry is found in .ssh/config, the
HostName from that entry is used.

This means that code that used GetHost should start using
GetHostUser.

Signed-off-by: Ron Minnich <[email protected]>
@rminnich rminnich merged commit b2f91f8 into u-root:main Jul 14, 2024
11 checks passed
rminnich added a commit to rminnich/cpu that referenced this pull request Jul 20, 2024
Since 2017 cpu used $USER as the user. Now that it supports
ssh, it needs better processing.

Add GetHostUser, which takes a string in [user@]host form,
and returns a host and user name as follows:
if user@host form, return the host and user.

Look up the host in .ssh/config; if found, and
there is a UserName record, return that UserName

Otherwise return host and $USER.

If a host entry is found in .ssh/config, the
HostName from that entry is used.

This means that code that used GetHost should start using
GetHostUser.

Signed-off-by: Ron Minnich <[email protected]>
Co-authored-by: Ron Minnich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants