Skip to content

ssh-copy-id feature added.#1

Open
abdullahenesoncu wants to merge 1 commit intoStaphylo:mainfrom
abdullahenesoncu:main
Open

ssh-copy-id feature added.#1
abdullahenesoncu wants to merge 1 commit intoStaphylo:mainfrom
abdullahenesoncu:main

Conversation

@abdullahenesoncu
Copy link

When -s or --ssh-copy-id flags are used, initially id_rsa is copied to host.

When -s or --ssh-copy-id flags are used, initially id_rsa is copied to
host.
Copy link
Owner

@Staphylo Staphylo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to this tool.
ssh-copy-id is a pretty good enhancement to have.


def copy_ssh_id(self):
self.create_ssh_id_if_not_exists()
cmd = 'ssh-copy-id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/id_rsa.pub -f '+self.host
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the array format for subprocess as it's done above.
Also do not use shell= because it's unsafe and definetly not needed here.
Last note is to use f-strings instead of string cocatenation.

Comment on lines +76 to +77
if self.ssh_copy_id:
self.copy_ssh_id()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer avoiding operations in the constructor of the Remote object this is bad style.
Could you move this logic in the main function before if args.init line 411

This way there is no need to add a new attribute in the class that doesn't matter after init.

Comment on lines +144 to +146
self.create_ssh_id_if_not_exists()
cmd = 'ssh-copy-id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/id_rsa.pub -f '+self.host
subprocess.run(cmd, shell=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer if the tool gracefully exits if there is no key rather than trying to create one.
It is not the place for this tool to create a ssh key in behalf of the user, especially with the risk of overriding an existing one.
Also the defaults that you set for the key are extremely low.
I for one do not believe in rsa anymore especially not below 8192 bits.

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.

2 participants