Skip to content
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

PE-23297 setup ssh access for windows #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions lib/beaker-task_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,27 @@ def run_puppet_access_login(user:, password: '~!@#$%^*-/ aZ', lifetime: '5y')
#@param [Host] Task runner
#@param [Array<Host> Nodes on which to run the task
#
#TODO: Implement on windows
def setup_ssh_access(task_runner, nodes)
ssh_dir_path = '/root/.ssh/'
win_ssh_path = '/home/Administrator/.ssh/'
if task_runner['platform'] =~ /windows/
ssh_dir_path = win_ssh_path
end

rsa_pub_path = "#{ssh_dir_path}/id_rsa.pub"

on task_runner, "ssh-keygen -f #{ssh_dir_path}/id_rsa -t rsa -N ''"
unless task_runner.file_exist?(rsa_pub_path)
on task_runner, "ssh-keygen -f #{ssh_dir_path}/id_rsa -t rsa -N ''"
end
public_key = on(task_runner, "cat #{rsa_pub_path}").stdout
create_remote_file(nodes, "#{rsa_pub_path}", public_key)
on(nodes, "cat #{rsa_pub_path} >> #{ssh_dir_path}/authorized_keys")
nodes.each do |host|
rsa_copy_path = '/root/.ssh/'
if host['platform'] =~ /windows/
rsa_copy_path = "/home/Administrator/.ssh/"
end
create_remote_file(host, "#{rsa_copy_path}/id_rsa_task_runner.pub", public_key)
on(host, "cat #{rsa_copy_path}/id_rsa_task_runner.pub >> #{rsa_copy_path}/authorized_keys")
end
end

def run_task(task_name:, params: nil, password: DEFAULT_PASSWORD, host: nil, format: 'human')
Expand Down