-
Notifications
You must be signed in to change notification settings - Fork 59
feat: add proxy_command parameter for SSH jump host configuration #530
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
Conversation
@njzjz 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
…prehensive tests Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
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.
@copilot, please run SSH tests when the environment variable DPDISPATCHER_TEST
is ssh
. Follow tests/test_ssh_context.py
. Our test is in the real ssh environment.
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Added environment variable check to SSH tests. Both |
@copilot could you use the same server, username, and password in |
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Updated both SSH test files to use the same server configuration as |
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
... Fixed the CI errors! The issues were:
The tests now use proper SSH options in proxy commands and should work reliably in the CI environment. Commit: b16148d |
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.
@copilot now it has the following error:
======================================================================
ERROR: test_rsync_direct_connection (tests.test_rsync_proxy.TestRsyncProxyCommand)
Test rsync without proxy command (direct connection).
----------------------------------------------------------------------
Traceback (most recent call last):
File "/dpdispatcher/tests/test_rsync_proxy.py", line 75, in test_rsync_direct_connection
rsync(
File "/dpdispatcher/dpdispatcher/utils/utils.py", line 147, in rsync
raise RuntimeError(f"Failed to run {cmd}: {err}")
RuntimeError: Failed to run ['rsync', '-az', '-e', 'ssh -o ConnectTimeout=10 -o BatchMode=yes -o StrictHostKeyChecking=no -p 22 -q -i /root/.ssh/id_rsa', '-q', '/tmp/tmpkioheaoh', 'root@server:/tmp/rsync_test/test_direct.txt']: b'rsync: [Receiver] change_dir#3 "/tmp/rsync_test" failed: No such file or directory (2)\nrsync error: errors selecting input/output files, dirs (code 3) at main.c(829) [Receiver=3.2.7]\n'
======================================================================
ERROR: test_rsync_with_additional_options (tests.test_rsync_proxy.TestRsyncProxyCommand)
Test rsync with proxy command and additional SSH options.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/dpdispatcher/tests/test_rsync_proxy.py", line 98, in test_rsync_with_additional_options
rsync(
File "/dpdispatcher/dpdispatcher/utils/utils.py", line 147, in rsync
raise RuntimeError(f"Failed to run {cmd}: {err}")
RuntimeError: Failed to run ['rsync', '-az', '-e', 'ssh -o ConnectTimeout=30 -o BatchMode=yes -o StrictHostKeyChecking=no -p 22 -q -i /root/.ssh/id_rsa -o ProxyCommand=ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa -W server:22 root@jumphost', '-q', '/tmp/tmp4hp1n7kh', 'root@server:/tmp/rsync_test/test_proxy.txt']: b'usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]\n [-c cipher_spec] [-D [bind_address:]port] [-E log_file]\n [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]\n [-J destination] [-L address] [-l login_name] [-m mac_spec]\n [-O ctl_cmd] [-o option] [-P tag] [-p port] [-R address]\n [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]\n destination [command [argument ...]]\n ssh [-Q query_option]\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(232) [sender=3.4.1]\n'
======================================================================
ERROR: test_rsync_with_proxy_command (tests.test_rsync_proxy.TestRsyncProxyCommand)
Test rsync with proxy command via jump host.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/dpdispatcher/tests/test_rsync_proxy.py", line 46, in test_rsync_with_proxy_command
rsync(
File "/dpdispatcher/dpdispatcher/utils/utils.py", line 147, in rsync
raise RuntimeError(f"Failed to run {cmd}: {err}")
RuntimeError: Failed to run ['rsync', '-az', '-e', 'ssh -o ConnectTimeout=10 -o BatchMode=yes -o StrictHostKeyChecking=no -p 22 -q -i /root/.ssh/id_rsa -o ProxyCommand=ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa -W server:22 root@jumphost', '-q', '/tmp/tmpfbvlxh40', 'root@server:/tmp/rsync_test/test_proxy.txt']: b'usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]\n [-c cipher_spec] [-D [bind_address:]port] [-E log_file]\n [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]\n [-J destination] [-L address] [-l login_name] [-m mac_spec]\n [-O ctl_cmd] [-o option] [-P tag] [-p port] [-R address]\n [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]\n destination [command [argument ...]]\n ssh [-Q query_option]\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(232) [sender=3.4.1]\n'
----------------------------------------------------------------------
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
... Fixed the CI errors! The issues were:
The tests should now pass in the SSH environment. 3a08764 |
@copilot CI got errors:
|
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
... Fixed the rsync command construction issue! The problem was that when using Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…examples to validation tests Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
@copilot use the conventional commit format for the PR title. |
Updated the PR title to follow conventional commit format: "feat: add proxy_command parameter for SSH jump host configuration". The title now uses the |
This PR adds support for SSH jump host connections using the standard OpenSSH
proxy_command
parameter. Users can now specify jump hosts using familiar OpenSSH ProxyCommand syntax directly.Problem
Previously, there was no built-in support for SSH jump host connections in dpdispatcher, making it difficult to connect to servers behind bastion hosts or through intermediate servers.
Solution
Added a single
proxy_command
parameter that accepts standard OpenSSH ProxyCommand syntax:Technical Implementation
proxy_command
for maximum simplicityTesting Infrastructure
Enhanced the CI/CD testing setup with a three-machine architecture:
DPDISPATCHER_TEST=ssh
Tests validate the complete jump host workflow:
test → jumphost → server
using actual SSH connections and rsync operations. The CI infrastructure automatically installs rsync and configures proper SSH key exchange between all containers.Bug Fixes
Fixed a critical issue in the rsync function where command construction was causing rsync to display help output instead of executing commands. The problem was resolved by properly converting command lists to escaped strings when using
shell=True
with subprocess.Benefits
Fixes #517.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.