-
Notifications
You must be signed in to change notification settings - Fork 2
Replace tilde at the beginning of the node.Auth.Keys.Path #9 #10
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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.
@u5surf any updates on this? |
@Samyak2 |
@u5surf no worries. Thank you for continuing this PR! |
Fixes #9
Replace tilde at the beginning of the node.Auth.Keys.Path