Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Replace tilde at the beginning of the node.Auth.Keys.Path #9 #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

u5surf
Copy link

@u5surf u5surf commented Sep 6, 2021

Fixes #9

Replace tilde at the beginning of the node.Auth.Keys.Path

Copy link
Collaborator

@Samyak2 Samyak2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

When I tested it out, it did not work. See the review comment below for details.

Additionally, the indentation looks off because you have used spaces instead of tabs. Running gofmt on the file should fix this.

internal/config/sshSetup.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@Samyak2 Samyak2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Upon further testing, I found another issue. While the key gets recognized and transferred (from the SetAuth function), the actual auth when running a command fails because the ~ is not expanded there.

This happens in the Connect function which in turn calls publicKey. So, there is a need to expand ~ just before this line:
https://github.com/psiayn/heiko/blob/fb8b464ec2d4308fde9a4d6cfbcc2762d2851783/internal/connection/establish_connection.go#L25

The following seems to work for now:

	if strings.HasPrefix(path, "~") {
		homePath, err := os.UserHomeDir()
		if err != nil {
			return []ssh.AuthMethod{}
		}
		path = strings.Replace(path, "~", homePath, 1)
	}

I understand that the publicKey function isn't great, it should have returned an error when the key wasn't found instead of causing authentication failures. This will have to be refactored later, but for now, just expanding the ~ works.

@Samyak2
Copy link
Collaborator

Samyak2 commented Nov 17, 2021

@u5surf any updates on this?

@u5surf
Copy link
Author

u5surf commented Nov 20, 2021

@Samyak2
I must apologize for my slow work.
I agree with addition the suggestion for now, And I'll add the commit of this.
I'm willing to finish the PR with adding this.

@Samyak2
Copy link
Collaborator

Samyak2 commented Nov 20, 2021

@u5surf no worries. Thank you for continuing this PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tilde (~) not recognized in key file path
2 participants