Skip to content

Commit

Permalink
Continue fix the ed25519 keys in Public Cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
pdostal committed Mar 1, 2024
1 parent fc1a056 commit 373f677
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions data/publiccloud/ssh_config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ControlMaster auto
ControlPath /tmp/ssh_%r_%h_%p
StrictHostKeyChecking no
HostKeyAlgorithms +ssh-rsa
IdentityFile %SSH_KEY%
ControlPersist 86400

8 changes: 4 additions & 4 deletions lib/publiccloud/provider.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Mojo::Base -base;
use publiccloud::instance;
use publiccloud::instances;
use publiccloud::ssh_interactive 'select_host_console';
use publiccloud::utils qw(is_azure is_gce is_ec2 is_hardened get_ssh_key_algorithm);
use publiccloud::utils qw(is_azure is_gce is_ec2 is_hardened get_ssh_private_key_path);
use Carp;
use List::Util qw(max);
use Data::Dumper;
Expand All @@ -31,7 +31,7 @@ has terraform_applied => 0;
has resource_name => sub { get_var('PUBLIC_CLOUD_RESOURCE_NAME', 'openqa-vm') };
has provider_client => undef;

has ssh_key => get_ssh_key_file_name();
has ssh_key => get_ssh_private_key_path();

=head1 METHODS
Expand Down Expand Up @@ -197,9 +197,9 @@ sub run_img_proof {
$cmd .= '--service-account-file "' . $args{credentials_file} . '" ' if ($args{credentials_file});
#TODO: this if is just dirty hack which needs to be replaced with something more sane ASAP.
$cmd .= '--access-key-id $AWS_ACCESS_KEY_ID --secret-access-key $AWS_SECRET_ACCESS_KEY ' if (is_ec2());
$cmd .= "--ssh-key-name '" . $args{key_name} . "' " if ($args{key_name});
$cmd .= '--ssh-key-name $(realpath ' . $args{key_name} . ') ' if ($args{key_name});
$cmd .= '-u ' . $args{user} . ' ' if ($args{user});
$cmd .= '--ssh-private-key-file "' . $self->ssh_key . '" ';
$cmd .= '--ssh-private-key-file $(realpath ' . $self->ssh_key . ') ';
$cmd .= '--running-instance-id "' . ($args{running_instance_id} // $args{instance}->instance_id) . '" ';
$cmd .= "--beta " if ($beta);
if ($exclude) {
Expand Down
9 changes: 4 additions & 5 deletions lib/publiccloud/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ our @EXPORT = qw(
register_openstack
register_addons_in_pc
gcloud_install
get_ssh_key_algorithm
get_ssh_private_key_path
prepare_ssh_tunnel
kill_packagekit
allow_openqa_port_selinux
Expand Down Expand Up @@ -255,20 +255,19 @@ sub gcloud_install {
record_info('GCE', script_output('gcloud version'));
}

sub get_ssh_key_file_name {
sub get_ssh_private_key_path {
my $algorithm = '~/.ssh/id_ed25519';
$algorithm = '~/.ssh/id_rsa' if (is_azure() || get_var('PUBLIC_CLOUD_SLES4SAP'));
return $algorithm;
}

sub prepare_ssh_tunnel {
my ($instance, $ssh_key) = @_;
$ssh_key //= '~/.ssh/id_rsa';
my ($instance) = @_;

# configure ssh client
my $ssh_config_url = data_url('publiccloud/ssh_config');
assert_script_run("curl $ssh_config_url -o ~/.ssh/config");
file_content_replace("~/.ssh/config", "%SSH_KEY%" => $ssh_key);
file_content_replace("~/.ssh/config", "%SSH_KEY%" => get_ssh_private_key_path());

# Create the ssh alias
assert_script_run(sprintf(q(echo -e 'Host sut\n Hostname %s' >> ~/.ssh/config), $instance->public_ip));
Expand Down
1 change: 0 additions & 1 deletion lib/sles4sap_publiccloud_basetest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use Exporter 'import';
use testapi;
use qesapdeployment;
use sles4sap_publiccloud;
use publiccloud::utils;

our @EXPORT = qw(cleanup import_context);

Expand Down

0 comments on commit 373f677

Please sign in to comment.