From 85e61147528d0f8b70a96553641dd8b086b73a94 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Wed, 10 Dec 2025 14:44:56 +0100 Subject: [PATCH] Generate a public key if needed with ssh-keygen SSH key is now generated if needed with `ssh-keygen` when spawning a VM using the Vagrant provider. Ticket: ENT-13485 Signed-off-by: Lars Erik Wik --- cf_remote/Vagrantfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cf_remote/Vagrantfile b/cf_remote/Vagrantfile index 569c062..8a88cde 100644 --- a/cf_remote/Vagrantfile +++ b/cf_remote/Vagrantfile @@ -26,7 +26,11 @@ Vagrant.configure("2") do |config| node.vm.box = VM_BOX node.vm.provision "shell" do |s| - ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip + ssh_pub_key_path = "#{Dir.home}/.ssh/id_rsa.pub" + if !File.file?(ssh_pub_key_path) + abort "SSH key not found at #{ssh_pub_key_path}. Please create one with: ssh-keygen -t rsa -b 4096" + end + ssh_pub_key = File.readlines(ssh_pub_key_path).first.strip s.inline = <<-SHELL echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys echo #{ssh_pub_key} >> /root/.ssh/authorized_keys