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.
Asked
Active
Viewed 4,384 times
4

Javier Buzzi
- 6,296
- 36
- 50
-
if you want to copy a file inside a docker image you would like to do it another way I think. – vinalti Feb 25 '22 at 11:38
-
@vinalti I have volumes with data inside docker-for-mac and i want to move them to colima for finish my transition. – Javier Buzzi Feb 25 '22 at 11:42
-
But then you better mount the volume directly on your Mac and copy it directly from there. – vinalti Feb 26 '22 at 15:09
-
I wanted to automate it, this was step one, this was step 2 https://stackoverflow.com/questions/71268183/how-to-migrate-volume-data-from-docker-for-mac-to-colima – Javier Buzzi Feb 28 '22 at 01:01
1 Answers
17
Quickest answer
colima ssh
Quick-ish answer using 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
Use root
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)
Using ~/.ssh/config
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.

Javier Buzzi
- 6,296
- 36
- 50