diff --git a/README.md b/README.md index 292ac8c..a356596 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,10 @@ ramon@email.com: alpha: /mnt/c/Users/me/src # local machine beta: ~/src # remote machine ramon@company.com: - project: development-254604 - box: ramon + - project: development-254604 + box: ramon + user: another_user # only needed if ramon_company_com is not the user + identity_file: /path/to/ssh-private # ~/.ssh/google_compute_engine by default ``` To start and create the mutagen session: diff --git a/lib/devbox_launcher/models/box.rb b/lib/devbox_launcher/models/box.rb index fb50f3f..ef55743 100644 --- a/lib/devbox_launcher/models/box.rb +++ b/lib/devbox_launcher/models/box.rb @@ -10,7 +10,6 @@ class Box ] WAIT_BOOT_IN_SECONDS = 10.freeze MAX_BOOT_RETRIES = 20 - DEFAULT_IDENTIFY_FILE_PATH = "~/.ssh/google_compute_engine".freeze SSH_CONFIG_PATH = File.expand_path("~/.ssh/config").freeze CONFIG_PATH = File.expand_path("~/.devbox_launcher.yml").freeze CONFIG = YAML.load_file(CONFIG_PATH).freeze @@ -104,7 +103,7 @@ def set_ssh_config! args = { "HostName" => description.ip, "User" => username, - "IdentityFile" => DEFAULT_IDENTIFY_FILE_PATH, + "IdentityFile" => box_config.identity_file, } args.each do |key, value| ssh_config.set(hostname, key, value) @@ -206,7 +205,7 @@ def hostname end def username - @username ||= account.gsub(/\W/, "_") + @username ||= box_config.user || account.gsub(/\W/, "_") end def account_config diff --git a/lib/devbox_launcher/models/box_config.rb b/lib/devbox_launcher/models/box_config.rb index a9d85ba..4de922e 100644 --- a/lib/devbox_launcher/models/box_config.rb +++ b/lib/devbox_launcher/models/box_config.rb @@ -1,6 +1,8 @@ module DevboxLauncher class BoxConfig + DEFAULT_IDENTIFY_FILE_PATH = "~/.ssh/google_compute_engine".freeze + attr_reader :config def initialize(config) @@ -19,5 +21,13 @@ def zone config[:zone] end + def user + config[:user] + end + + def identity_file + config[:identity_file] || DEFAULT_IDENTIFY_FILE_PATH + end + end end