Closed warjiang closed 7 months ago
@lonnywong plz help
@warjiang Does openssh work properly?
@warjiang Does openssh work properly?
Yeah, it works
openssh supports #
without '
and "
:
Host test
LocalCommand echo Hello# World
PermitLocalCommand yes
Need to study how openssh does it. But I've been busy recently.
@lonnywong
First i should admit that i have little knowledge of openssh, even bunch of knowledge came from daily usage 🤣 .
May be it's not right time to talk further, you can recheck this when you are free. Feel free to review it 😄 .
What i want to express is that, the ssh_config
pkg cannot parse #
char in side string literal.
The test code as follow:
func main() {
configData := `Host test
LocalCommand echo Hello'#' World
PermitLocalCommand yes`
cfg, err := ssh_config.Decode(strings.NewReader(configData))
if err != nil {
panic(err)
}
v, err := cfg.Get("test", "LocalCommand")
if err != nil {
panic(err)
}
debug("value is %s", v)
}
before fixed:
after fixed:
Apart from that, i've tested in openssh client, i mock a ssh config file like following:
Host wap1
LocalCommand echo Hello'#' World
PermitLocalCommand yes
it's equla to command echo Hello'#' World
no echo Hello'
what i do is that handel the #
within string literal, it's not enough, but it can work currentlly. After a brief view of openssh: https://github.com/openssh/openssh-portable/blob/master/readconf.c,
openssh lib also handle the ssh config with ast like tokenizer, lexer and so on. But the token is much more than ssh_config ðŸ˜
May we can talk it further in the futhre when free.
@warjiang How about we make some changes like this:
Host comment
Key1 = Value1 # This is part of the value, not a comment
Key2 Value2 # This is a comment, not part of the value
The value of Key1
is Value1 # This is part of the value, not a comment
. And the value of Key2
is Value2
.
@warjiang How about we make some changes like this:
Host comment Key1 = Value1 # This is part of the value, not a comment Key2 Value2 # This is a comment, not part of the value
The value of
Key1
isValue1 # This is part of the value, not a comment
. And the value ofKey2
isValue2
.
we should distinguish scene of #
#
in side single quote or doule quote
in this case, #
should be treated as a common literal#
not in side single quote or doule quote
in this case, #
should be treated as grammar of commentso @lonnywong should change code as following, if you want #
as part of value
Host comment
Key1 = 'Value1 # This is part of the value, not a comment'
Key2 Value2 # This is a comment, not part of the value
It's not clear whether the value 'Value1 # This is part of the value, not a comment'
contains single quotes or not.
I think =
means there is no comment at the end, which is simple and easy to distinguish. It's not exactly the same as openssh, but it's worth it.
i've made serval test cases it in my local enviroment
Host wap
LocalCommand = echo Value1 # This is part of the value, not a comment
PermitLocalCommand yes
Host wap
LocalCommand echo Value1 # This is part of the value, not a comment
PermitLocalCommand yes
Conculsion: whether use equal sign, it turns out the same effect.
if wrap #
with single quote as follow:
Host wap
LocalCommand echo 'Value1 # This is part of the value, not a comment'
PermitLocalCommand yes
I mean we change the code to do that.
It's not clear whether the value
'Value1 # This is part of the value, not a comment'
contains single quotes or not.I think
=
means there is no comment at the end, which is simple and easy to distinguish. It's not exactly the same as openssh, but it's worth it.
maybe you are right, but it will casued some extra knowledge of another version of ssh config (like config of tssh) 😆 .
I mean we change the code to do that.
i can try it, but maybe we can use option to let user to choose whehter enable this feature.
how about another im tools like wechat or tg? may be we can talk it for further. the work under trzsz is very useful for me, maybe i can take part in these project in deep. 🤔
i can try it, but maybe we can use option to let user to choose whehter enable this feature.
I think most people will not use =
in ssh config, even fewer use =
and add comments at the end of the line.
We just need to document the new features of =
in the new version.
how about another im tools like wechat or tg? may be we can talk it for further. the work under trzsz is very useful for me, maybe i can take part in these project in deep. 🤔
There's a QQ group at the bottom of README.
I think most people will not use
=
in ssh config, even fewer use=
and add comments at the end of the line.We just need to document the new features of
=
in the new version.
that's true~ i'll try it later 🔧
I've implemented this feature by add lexRReservedvalue
state. After detect equal, it will go to state of checking lexRReservedvalue
.
I've implemented this feature by add
lexRReservedvalue
state. After detect equal, it will go to state of checkinglexRReservedvalue
.
for the ssh config as following:
Host comment
Key1 = Value1 # This is part of the value, not a comment
Key2 Value2 # This is a comment, not part of the value
the test case like following:
I will write the documentation and update it this weekend.
the ssh config as follow:
value after '#' in line of ProxyCommand will be truncate. more detail can refer following links: https://github.com/trzsz/ssh_config/pull/2