Looking for the steps needed to SSH into colima
, this is too new and the documentation is a bit scarce. I need to copy over the volumes, and running scp
seems ideal.
colima ssh
ssh
(tmpconfig=$(mktemp); limactl show-ssh --format config colima > $tmpconfig; ssh -F $tmpconfig lima-colima)
While i'm at it, here is the scp
:
(tmpconfig=$(mktemp); limactl show-ssh --format config colima > $tmpconfig; scp -F $tmpconfig lima-colima:/path/to/somewhere/ .)
I would love to have written this with a file descriptor, unfortunately, ssh does not like it when you pass a file descriptor in the -F
argument, such as: ssh -F <(limactl show-ssh --format config colima) lima-colima
If you need to auth as root
such as ssh -F $tmpconfig root@lima-colima
you'll notice it won't work, your user will always be used, here are the steps to change that.
(
tmpconfig=$(mktemp);
# Need to remove the 'ControlPath' and 'User', and add 'ForwardAgent'
(limactl show-ssh --format config colima | grep -v "^ ControlPath\| ^User"; echo " ForwardAgent=yes") > $tmpconfig;
# Setup root account
ssh -F $tmpconfig $USER@lima-colima "sudo mkdir -p /root/.ssh/; sudo cp ~/.ssh/authorized_keys /root/.ssh/authorized_keys"
)
The command above changes slightly to:
(tmpconfig=$(mktemp); (limactl show-ssh --format config colima | grep -v "^ ControlPath\| ^User"; echo " ForwardAgent=yes") > $tmpconfig; ssh -F $tmpconfig root@lima-colima)
If you're going to be ssh
-ing into colima
a lot, you can alway just skip all the fuss and simply add it into your ~/.ssh/config
and just call it "normally".
# run this ONLY ONCE!!!
limactl show-ssh --format config colima >> ~/.ssh/config
And then just call ssh
/scp
"normally":
ssh lima-colima
scp lima-colima:/path/blah/foo .
Personally, I don't like to clutter my ~/.ssh/config
, but do what best works for you.