寻找SSH进入colima所需的步骤,这太新了,文档也有点缺乏。我需要复制这些卷,运行scp似乎很理想。
发布于 2022-02-25 11:33:54
快速回答
我发现最直截了当的方法是:
(tmpconfig=$(mktemp); limactl show-ssh --format config colima > $tmpconfig; ssh -F $tmpconfig lima-colima)我正在做这件事,这是scp
(tmpconfig=$(mktemp); limactl show-ssh --format config colima > $tmpconfig; scp -F $tmpconfig lima-colima:/path/to/somewhere/ .)很遗憾,ssh不喜欢在-F参数中传递文件描述符,例如:ssh -F <(limactl show-ssh --format config colima) lima-colima
使用根
如果您需要使用root (如ssh -F $tmpconfig root@lima-colima ),您会注意到它无法工作,您的用户将始终被使用,下面是更改该操作的步骤。
(
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"
)上面的命令稍微更改为:
(tmpconfig=$(mktemp); (limactl show-ssh --format config colima | grep -v "^ ControlPath\| ^User"; echo " ForwardAgent=yes") > $tmpconfig; ssh -F $tmpconfig root@lima-colima)使用~/..ssh/config
如果您要经常使用ssh-ing to colima,您可以跳过所有的小题大做,只需将其添加到~/.ssh/config中,只需将其称为“正常”即可。
# run this ONLY ONCE!!!
limactl show-ssh --format config colima >> ~/.ssh/config然后只需调用ssh/scp“通常”:
ssh lima-colima
scp lima-colima:/path/blah/foo .就我个人而言,我不喜欢搅乱我的~/.ssh/config__,但是做最适合你的事情。
https://stackoverflow.com/questions/71265221
复制相似问题