-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
SSH extension #1363
SSH extension #1363
Conversation
If this PR is for a new extension or change to an existing extension, use the following to try out the changes in this PR:
|
SSH for Azure VM |
hi @rlrossiter we'll look at the issue and keep offline syncing with you. |
CLI arguments were changed from extra to argument with None defaults in custom. Changed resource_group to resource_group_name argument for auto-population from cli-core. Removed Python 2 and added new Python 3s to setup.
def _get_ssh_path(): | ||
ssh_path = "ssh" | ||
|
||
if platform.system() == 'Windows': |
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.
Is it possible there is no ssh
in other platform ?
@mock.patch('azext_ssh.custom._do_ssh_op') | ||
@mock.patch('azext_ssh.custom.ssh_utils') | ||
@mock.patch('functools.partial') | ||
def test_ssh_config(self, mock_partial, mock_ssh_utils, mock_do_op): |
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.
Hi @rlrossiter , which python version are you using to run this test ? It always failed from my side (python 3.8).
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.
The version isn't the problem, the code changed and broke the unit tests. A lot of them are now failing for me too because of the code changes (Python 3.6).
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.
Hi @rlrossiter, what other tests also failed for you ? As you can see from the CI log, all other tests are passed. Did you use the latest azure-cli
dev branch and rerun azdev setup
? It should be only this test failed. And the reason has something to do with functions.partial
. I'm not sure the root cause currently, will investigate deeper.
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.
I guess I didn't have all of the commits you added to this branch. Will re-pull and take a look if I get a chance.
] | ||
|
||
DEPENDENCIES = [ | ||
'paramiko==2.6.0', |
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.
Hi @rlrossiter, seems we do not use these dependencies in our code any more ? Can we remove them ?
op_call(ssh_ip, username, cert_file, private_key_file) | ||
|
||
|
||
def _prepare_jwk_data(public_key_file): |
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.
These codes were previously in azure-cli-core. I move it here because we think it is ssh certificate specific. In azure-cli-core, we expose a function get_msal_token
in _profile.Profile to make it simple and clean. @rlrossiter @danybeam, could you please help review it ?
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.
I don't like the use of the _profile
module from core outside of core because modules that start with _ usually denote that it's a private module that shouldn't be used outside of the repo it lives in. That's why I put this in azure-cli-core to start
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.
Yes, I agree with you about the private module part. For this _profile
case, as there are lots of examples in extensions to use _profile
directly, so I think we can just follow it. From cli-core perspective, we have an internal discussion, and we think we'd better not include SSH specific logic in it.
src/ssh/azext_ssh/custom.py
Outdated
profile = Profile(cli_ctx=cmd.cli_ctx) | ||
username, certificate = profile.get_msal_token(scopes, data) | ||
|
||
cert_file = _write_cert_file(public_key_file, username, certificate) |
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.
Hi @rlrossiter , previously there is a fixed [email protected]
in certificate head, which is weird to me. I replace it with username
, could you please help check whether it is right ?
Previous code in azure-cli-core
class SSHCredentials(object):
def __init__(self, username, cert):
self.username = username
self.certificate = "[email protected] " + cert
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.
The original was correct as that was the type of certificate the file was (it's required by SSH). The username is encoded as part of the base64 bytes written to the file. The username was passed back alongside the credentials but not part of the certificate in order to know who to SSH as
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.
Thanks for your explain. Yes, I decode the certificate and find [email protected]
is in it. I have change it back. You can have a look.
Could you please share more about this? Is there any document which explain it? It's still weird to me that why it is a fixed name in the certificate. Thanks in advance.
Add an extension used for AAD-based SSH for Azure VMs.
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
azdev style <YOUR_EXT>
locally? (pip install azdev
required)python scripts/ci/test_index.py -q
locally?For new extensions: