Skip to content

Allow NetworkService to be used without an explicit SSH username#1863

Open
ozan956 wants to merge 2 commits into
labgrid-project:masterfrom
ozan956:fix/ssh-defaults
Open

Allow NetworkService to be used without an explicit SSH username#1863
ozan956 wants to merge 2 commits into
labgrid-project:masterfrom
ozan956:fix/ssh-defaults

Conversation

@ozan956
Copy link
Copy Markdown

@ozan956 ozan956 commented May 7, 2026

Allow NetworkService to be used without an explicit SSH username.

Until now, NetworkService.username was required and SSHDriver always passed
it through to ssh, scp, etc. That prevented setups where the SSH user should
come from the local SSH configuration or the default SSH user resolution.

This change makes NetworkService.username optional and updates SSHDriver to
only pass -l <username> or user@host when a username is explicitly set.

The client-side fallback path in labgrid.remote.client also no longer forces
username="root". While adding regression coverage for that path, this also
surfaced that the fallback resource creation needs name=None, which is now
passed explicitly.

I verified the change with some tests called test_run_no_username, test_put_get_no_username and test_get_ssh_no_username for the no-username paths.

Checklist

  • Documentation for the feature
  • Tests for the feature
  • PR has been tested

ozan956 added 2 commits May 7, 2026 11:22
So far, `NetworkService.username` was required and `SSHDriver` always
passed it to `ssh` and `scp`. This prevented setups where the SSH
username is intentionally resolved through the user's SSH configuration
or by the default SSH user selection.

This change makes `NetworkService.username` optional and updates
`SSHDriver` to only pass `-l <username>` or `user@host` when a username
is explicitly set.

In addition, the client-side fallback `NetworkService` creation path no
longer forces `username="root"` and now instantiates the resource with
`name=None`, so ad-hoc SSH access can use the normal SSH configuration
of the user.

This improves compatibility with existing SSH setups and avoids
hardcoding a username when it is not actually required.

Add regression tests covering the no-username path in SSHDriver and the
client-side fallback NetworkService creation.

Signed-off-by: Ozan Durgut <ozan.durgut@analog.com>
Clarify that `NetworkService.username` is optional.

If no username is configured on `NetworkService` or `SSHDriver`,
labgrid lets SSH resolve the username through the local SSH
configuration or the default SSH user selection.

Signed-off-by: Ozan Durgut <ozan.durgut@analog.com>
@ozan956 ozan956 force-pushed the fix/ssh-defaults branch from 3118e12 to 37e4cd1 Compare May 7, 2026 09:22
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.9%. Comparing base (ec5ec29) to head (37e4cd1).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1863     +/-   ##
========================================
+ Coverage    45.8%   45.9%   +0.1%     
========================================
  Files         182     182             
  Lines       14720   14738     +18     
========================================
+ Hits         6743    6775     +32     
+ Misses       7977    7963     -14     
Flag Coverage Δ
3.10 45.9% <100.0%> (+0.1%) ⬆️
3.11 45.9% <100.0%> (+0.1%) ⬆️
3.12 45.9% <100.0%> (+0.1%) ⬆️
3.13 45.9% <100.0%> (+0.1%) ⬆️
3.14 45.9% <100.0%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant