-
Notifications
You must be signed in to change notification settings - Fork 156
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
ProxyCommand %h not replaced #520
Comments
It looks like the '%h' substitution during config file parsing isn't getting the hostname, but in a quick test I was not able to reproduce that here. Can you show the call you are making to AsyncSSH to make the connection? Are you passing in that IP of 10.38.119.40 directly as the host to connect to, or is there something more involved going on there? |
|
I set up a configuration here with a jump server connection using DynamicForward and a ProxyCommand matching what you have here, but I'm still not able to reproduce the problem. The substituted hostname properly shows up in the debug output, and the proper host is contacted by the jump server. I'm not sure what to try next. |
I'm not sure if it's an option for you to use ProxyJump instead of ProxyCommand, letting AsyncSSH open the connection to the jump server instead of running it yourself in the background and using SOCKS to connect through it, but AsyncSSH does support that if you wanted to try it. It can be done either via ProxyJump in the config file or by passing the jump host info as the "tunnel" argument on an asyncssh.connect(), either referencing a previously opened SSHClientConnection or as a string containing a hostname and optional port of the jump server. That said, I would like to get the bottom of why the substitutions aren't working for you, as they should. I just don't see anything obvious in the code which would cause this, and can't get it to happen here. If you're up for it, perhaps some debugging could be added into AsyncSSH on your system to try and narrow it down. |
I cannot use Jump Server because I'm using this option to multiplex session, which is not supported by asyncssh. I'm trying to find workaround :) I can try to add more debug to asyncssh (or suzieq if needed). EDIT :
|
Found out that Line 424 in 8665c5f
That's why substitution does not work |
The line you identified in the SSHClientConfig constructor is called from the load() class method of SSHConfig, which gets the value from the prepare() method in SSHClientConfigOptions, and that gets the value from the asyncssh.connect() call (among other calls). So, if a "host" argument is being passed into the call to connect(), it should end up being filled into the a config object when connect() creates the "new_options" object. Based on the code you provided above, the host argument to connect() should be self.address in suzieq. Can you confirm self.address is being passed into connect(), and that it has a proper value? Assuming it is, can you see what this value ends up being in SSHClientConnectionOptions.prepare() and SSHClientConfig.load()? This path is working correctly for me, but somehow in your environment it seems like the host value is getting lost somewhere along the way. |
I put some logger message on
Here's the output log :
So yes the self.adress is okay. But the problem is in So, I put a log in the I supposed this is because, when When substitution is done, it's done before the |
If you specify "config" explicitly as an argument when constructing an SSHClientConnectionOptions object, I believe that causes the config file parsing to happen at the time of that call. In this case, the "host" argument is not being specified until later, but by then the substitutions done when reading the config file have already happened. If you want this to work, I think you are going to need to defer passing in the "config" option until the connect() call if you want the host substitution to work. Alternately, the host is know at the point where suzieq's init_ssh_options() is called, it may be sufficient to pass in the "host" argument within that. The intent behind this behavior is to allow you to pay the cost of parsing the config file and any other operations related to constructing the SSHClientConnectionOptions only once, and any future options are built up incrementally from that. You'd only parse the config file again if the "config" argument is passed in again. |
I'm using another library (suzieq) which use asyncssh library.
I'm providing ssh config file with ProxyCommand option for trying to multiplex ssh session with netcat.
It's working with openssh client, but it seems that asyncssh does not replace the token
%h
from theProxyCommand
option :As you can see, we see
''
instead of10.38.119.40
.Here's my ssh config file :
Just for information, I'm starting the ssh connection to jumpserver before running Python with this command :
ssh jumpserver -F /home/suzieq/parquet/ssh_cred_conf/config -N &
The text was updated successfully, but these errors were encountered: