cli icon indicating copy to clipboard operation
cli copied to clipboard

Lando creates empty .ssh folder in app root

Open michaellopez opened this issue 2 years ago • 4 comments

Thanks for Lando! I would like to report a simple but annoying bug.

Due to https://github.com/lando/cli/commit/582e22a6e01239c8af0448a3b89b6660dfc20248 when setting home: '' in ~/.lando/config.yml to avoid mounting the home folder as described in https://github.com/lando/lando/issues/2635#issuecomment-877473886 Lando creates an empty folder named .ssh in the app root (next to .lando.yml)

This happens since lando.config.home is an empty string, so path.join(lando.config.home, '.ssh') evaluates to .ssh and therefore creates the folder in the working directory.

Would you like a PR or is this simple enough for you to quick fix with something like for lines 64-66:

const sshDir = lando.config.home && path.join(lando.config.home, '.ssh');
  // Ensure some dirs exist before we start
  _.forEach([caDir, sshDir], dir => dir && mkdirp.sync(dir));

Thanks for all your efforts!

michaellopez avatar Mar 08 '22 18:03 michaellopez

A PR would be great @michaellopez, thanks for pointing it out!

reynoldsalec avatar Mar 09 '22 18:03 reynoldsalec

@reynoldsalec Here you go https://github.com/lando/cli/pull/135

michaellopez avatar Mar 10 '22 09:03 michaellopez

You can avoid creating rogue .ssh paths by using an absolute path as the value... eg

home: '/Users/al/.lando-home-jail'

then it'll go and create the .ssh dir in that root. the .ssh dir is used to load your id_rsa up... so, if you change the home dir, you should probably also copy

\cp -fR ~/.gitconfig ~/.lando-home-jail \cp -fR ~/.ssh/id_rsa ~/.lando-home-jail/.ssh

almunnings avatar May 18 '22 06:05 almunnings

@sonuku That's pretty clever, thanks

michaellopez avatar May 18 '22 09:05 michaellopez