-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add helper output for connecting after running add-to-ssh-agent #32
Conversation
The function definition header has help how to connect to the server whose key we've added to the ssh-agent, on the other hand the tabular output is both different order and would still require knowledge of the ssh parameters. This change fills in the command with the server variables and adds some extra flags that help to be less noisy later: not adding the server's key to the known hosts file, and not checking the server's key. ``` Hostname Port Username 123.123.123.123 12345 faculty Connect to the server by: ssh [email protected] -p 12345 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ``` It should work both on Linux/Mac and Windows as the relevant null device is substituted in the command example. Signed-off-by: Gergely Imreh <[email protected]>
Signed-off-by: Gergely Imreh <[email protected]>
Since older Pythons don't do f-strings, duh. Signed-off-by: Gergely Imreh <[email protected]>
Otherwise can run into issues that black formats lines one way, but flake8 doesn't accept the formatting choices. Signed-off-by: Gergely Imreh <[email protected]>
…on 2 This reverts commit fe1bfcb.
Signed-off-by: Gergely Imreh <[email protected]>
Signed-off-by: Gergely Imreh <[email protected]>
What's the intended use case for this? I don't see an advantage of executing the printed SSH command over using |
One of the recent PRs added recently added this function of adding the
remote server's key to the ssh-agent. The output of that function gives
that host/port/username table, and the docstring of the function has hint
how to use it. Don't think anyone will go there to check, if the function
outputs those server infos, then should be able to use it easily.
I agree with using "faculty shell". Here I am trying to improve on the
usability of "faculty server add-to-ssh-agent", since someone already
needed it, then make it easier?
…On Thu, Mar 19, 2020, 16:26 Scott Stevenson ***@***.***> wrote:
What's the intended use case for this? I don't see an advantage of
executing the printed SSH command over using faculty shell <project>
<container>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAJPT347RCC7AHX2ZUDNXLRIJBUFANCNFSM4LPLZNRA>
.
|
The VS Code requires something like the connection string this PR adds, but doesn't need the |
The awkward string formatting is necessary as `black` doesn't break long strings but `flake8` despises them. Signed-off-by: Gergely Imreh <[email protected]>
@srstevenson I am okay to just drop this whole thing, if it's not needed. Your comment make sense, though then I'm not reconciled with the what the docstring in the code says, which also misleads about the use case (as it projects as faculty-cli/faculty_cli/cli.py Lines 721 to 722 in 96b83ab
Based on your comment, I guess that docsting needs an update as well, or removing that part entirely, and documenting for the CLI the use case with the IDEs you mentioned + recommending |
Pinging @liamcoatman and @brynmathias for thoughts, as they're more familiar with the use case for this than me. |
Signed-off-by: Gergely Imreh <[email protected]>
Btw, great, that ignoring the long line error (E501) just makes a bunch of warnings (W503) an error it seems, and that's coming from |
Signed-off-by: Gergely Imreh <[email protected]>
I agree the example could confuse the user about the intended use case (and the overlap in functionality with
I don't think any other commands have overly verbose documentation, so we should probably follow that example. |
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 agree with other commenters in that I don't understand the use case for this addition. Adding this output implies that running this command then manually SSHing to the server is a recommended flow, however I think we want to encourage people to continue to use faculty shell
.
I think it would be useful for my understanding if you could propose a use case, even if hypothetical.
Aside from this I've left a few minor comments on the implementation.
[flake8] | ||
# Ignore long line errors, and rely on the formatting done properly by black | ||
# Also ignore "Line break occurred before a binary operator" also coming from black | ||
ignore = E501,W503 |
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.
Can we instead put this in setup.cfg
, as in https://github.com/facultyai/faculty/blob/master/setup.cfg ?
It should then get picked up by linter plugins in peoples' editors.
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.
That's good info, thanks! Just getting to learn the number of different configs that one can use to set these tooling (just like pyproject.toml
mentioned earlier). Will try that out too, and it makes complete sense putting it where it has the best effect.
@@ -1158,7 +1165,7 @@ def put(project, local, remote, server): | |||
"-P", | |||
str(details.port), | |||
os.path.expanduser(local), | |||
u"{}@{}:{}".format( | |||
"{}@{}:{}".format( |
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.
We've not yet made the decision to drop Python 2 support. Can we leave these unicode literals until then?
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.
Looking back through the changes, I believe this is done by a newer version of black (than defined in tox.ini
) cleaning that up, and when I realised that I run locally a different version and downgraded, I didn't go back to undo the changes that the original (version 19?) done. Totally makes sense, and will watch out for this later.
click.echo( | ||
"\n" | ||
+ "Login to the server with:\n" | ||
+ "ssh {}@{} -p {} -o UserKnownHostsFile={} -o StrictHostKeyChecking=no".format( | ||
details.username, details.hostname, details.port, os.devnull | ||
) | ||
) |
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.
Might this be a little tidier as:
click.echo( | |
"\n" | |
+ "Login to the server with:\n" | |
+ "ssh {}@{} -p {} -o UserKnownHostsFile={} -o StrictHostKeyChecking=no".format( | |
details.username, details.hostname, details.port, os.devnull | |
) | |
) | |
click.echo("") | |
click.echo("Login to the server with:") | |
click.echo( | |
"ssh {}@{} -p {} -o UserKnownHostsFile={} -o StrictHostKeyChecking=no".format( | |
details.username, details.hostname, details.port, os.devnull | |
) | |
) |
We already compose the output like this in https://github.com/facultyai/faculty-cli/blob/master/faculty_cli/cli.py#L851
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.
Ah, thanks for the example! I was wondering of a setup like this, but haven't looked deep enough. Makes complete sense!
Hey, thanks for the feedback everyone. I guess I dived in this without much critical thinking, rather "improvements for improvements' sake". Based on the different current uses. mentioned, indeed there's no need for the core of this PR at all. I'm just going to close this. There might be a handful of housekeeping improvements (not related to the ssh part, but popped up while developing this PR, such as the flake8-black potential tug-o-war) as discussed in the comments, but those don't seem pressing or completely clear cut beneficial just yet. Cheers for all the teaching, much appreciated! |
Sorry this did not make it through @imrehg - we appreciate your taking the initiative to further improve the tool! |
The function definition header has help how to connect to the server whose key we've added to the ssh-agent, on the other hand the tabular output is both different order and would still require knowledge of the ssh parameters.
This change fills in the command with the server variables and adds some extra flags that help to be less noisy later: not adding the server's key to the known hosts file, and not checking the server's key.
It should work both on Linux/Mac and Windows as the relevant null device is substituted in the command example.
Signed-off-by: Gergely Imreh [email protected]