labgrid icon indicating copy to clipboard operation
labgrid copied to clipboard

ShellDriver: add optional arg dest_authorized_keys

Open pmelange opened this issue 10 months ago • 4 comments

ShellDriver: add optional arg dest_authorized_keys

Add an addition optional arg "dest_authorized_keys" with the default value of ~/.ssh/authorized_keys,

An example where this might be used is when an embedded system uses dropbear as it's ssh server daemon. In such a case, the authorized_keys file is /etc/dropbear/authorized_keys

Additionally, the put_key_file takes an optional dest_authorized_keys function parameter which defaults to the above arg.

Update docs

Checklist

  • [x] Documentation for the feature
  • [x] Tests for the feature: runtime test with the arg set and without the arg set.
  • [x] PR has been tested locally

Fixes: #1626

pmelange avatar Mar 10 '25 12:03 pmelange

Isn't a keyword argument with default for the put_ssh_key() function not enought to achieve this? Do we need the additional driver argument?

Emantor avatar Apr 08 '25 13:04 Emantor

Isn't a keyword argument with default for the put_ssh_key() function not enought to achieve this? Do we need the additional driver argument?

put_ssh_key() is called from on_activate(). So, no. I don't think it would work as you suggested.

https://github.com/labgrid-project/labgrid/blob/0b9dd26940103cde1fc9c72384ee01ef5cdc933d/labgrid/driver/shelldriver.py#L70-L75

pmelange avatar Apr 08 '25 14:04 pmelange

Making this an automatic upload on keyfile availability on activation is a design decision I'd like to revise with the original author. I'll have stern talking to with myself, your implementation looks fine and changing this is not something I want to do at this point in time. Is there a specific reason for switching to """ for the f-strings? The logging functions will also need to be fixed to not use f-strings.

Emantor avatar Apr 09 '25 06:04 Emantor

Making this an automatic upload on keyfile availability on activation is a design decision I'd like to revise with the original author. I'll have stern talking to with myself, your implementation looks fine and changing this is not something I want to do at this point in time. Is there a specific reason for switching to """ for the f-strings? The logging functions will also need to be fixed to not use f-strings.

I can imagine that removing the put_ssh_key() from on_activate() will break a lot of people's code. So making that change, which is totally the decision of the maintainers, is totally fine with me as I would be aware of it and can modify my code.

I used the """ f-strings because it seems (from the code that I have looked at within labgrid) that it is the most-often style used. I personally also find that style quite readable. Could you please explain what you mean by "The logging functions will also need to be fixed to not use f-strings"?

pmelange avatar Apr 09 '25 07:04 pmelange