You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "pietrygamat (via GitHub)" <gi...@apache.org> on 2023/03/27 22:27:55 UTC
[GitHub] [mina-sshd] pietrygamat opened a new issue, #351: Invalid port resolved for ProxyJump from ~/.ssh/config
pietrygamat opened a new issue, #351:
URL: https://github.com/apache/mina-sshd/issues/351
### Version
2.9.2
### Bug description
I have a ~/.ssh/config similar to this:
```
Host bastion
Hostname 1.2.3.4
User username
IdentityFile ~/.ssh/id_rsa
Host server1
ProxyJump bastion
```
Commandline ssh client works no problem for calls such as
```
ssh serverUser@server1
ssh bastion
```
and correctly assume port 22 is to be used.
However the sshClient does not assume default port for jumps, and results in exception:
```
try(SshClient sshClient = SshClient.setUpDefaultClient()) {
sshClient.setHostConfigEntryResolver(new ConfigFileHostEntryResolver(sshConfigFile));
sshClient.start();
sshClient.connect("serverUser", "server1", 22);
} catch (Exception e) {
throw new IllegalStateException(e);
}
```
### Actual behavior
The jump entry is resolved as `bastion: username@1.2.3.4:-1`
```
Caused by: java.lang.IllegalArgumentException: Invalid port: -1
at org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:213) ~[sshd-common-2.9.2.jar:2.9.2]
at org.apache.sshd.common.util.ValidateUtils.throwIllegalArgumentException(ValidateUtils.java:179) ~[sshd-common-2.9.2.jar:2.9.2]
at org.apache.sshd.common.util.ValidateUtils.checkTrue(ValidateUtils.java:162) ~[sshd-common-2.9.2.jar:2.9.2]
at org.apache.sshd.client.SshClient.doConnect(SshClient.java:556) ~[sshd-core-2.9.2.jar:2.9.2]
at org.apache.sshd.client.SshClient.doConnect(SshClient.java:568) ~[sshd-core-2.9.2.jar:2.9.2]
at org.apache.sshd.client.SshClient.connect(SshClient.java:546) ~[sshd-core-2.9.2.jar:2.9.2]
at org.apache.sshd.client.SshClient.connect(SshClient.java:538) ~[sshd-core-2.9.2.jar:2.9.2]
at org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:74) ~[sshd-core-2.9.2.jar:2.9.2]
at org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:57) ~[sshd-core-2.9.2.jar:2.9.2]
```
### Expected behavior
Perhaps `org.apache.sshd.client.config.hosts.HostConfigEntry#resolvePort(int, int)` when given two invalid arguments:
originalPort = -1 // from parsing URI
entryPort = 0 // from
should resolve to protocol default, and act the same way as commandline client would given the same set of data?
### Relevant log output
_No response_
### Other information
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [I] Invalid port resolved for ProxyJump from ~/.ssh/config [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #351:
URL: https://github.com/apache/mina-sshd/issues/351#issuecomment-2798838545
I've created new issue #727 for this. Your case is different: there is no host entry for the jump host. In the original report, there was an entry for the jump host.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [I] Invalid port resolved for ProxyJump from ~/.ssh/config [mina-sshd]
Posted by "chylek-qr (via GitHub)" <gi...@apache.org>.
chylek-qr commented on issue #351:
URL: https://github.com/apache/mina-sshd/issues/351#issuecomment-2798753586
It's not resolved in 2.15.0. I redacted the username and domain names, but `.ssh/config` looks like this:
```
Host example.proxy
User username
Hostname 192.168.123.123
ProxyJump username@example.com
```
The proxy jump gets parsed as `ssh://username@example.com`, and then https://github.com/apache/mina-sshd/blob/master/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java#L723 gets `-1` as the port, passes it into the jump `HostConfigEntry`, and it fails validation.
```
java.lang.IllegalArgumentException: Invalid port: -1
at org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:234)
at org.apache.sshd.common.util.ValidateUtils.throwIllegalArgumentException(ValidateUtils.java:200)
at org.apache.sshd.common.util.ValidateUtils.checkTrue(ValidateUtils.java:183)
at org.apache.sshd.client.SshClient.doConnect(SshClient.java:562)
at org.apache.sshd.client.SshClient.doConnect(SshClient.java:574)
at org.apache.sshd.client.SshClient.connect(SshClient.java:552)
at org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:199)
at org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:188)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
[GitHub] [mina-sshd] tomaswolf commented on issue #351: Invalid port resolved for ProxyJump from ~/.ssh/config
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #351:
URL: https://github.com/apache/mina-sshd/issues/351#issuecomment-1501167594
This was fixed by PR #353 done for issue #281.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
[GitHub] [mina-sshd] tomaswolf closed issue #351: Invalid port resolved for ProxyJump from ~/.ssh/config
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf closed issue #351: Invalid port resolved for ProxyJump from ~/.ssh/config
URL: https://github.com/apache/mina-sshd/issues/351
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org