wubbl0rz / VmChamp

Simple and fast creation of throwaway VMs on your local machine. Connect via SSH in just a few seconds.
https://github.com/wubbl0rz/VmChamp
GNU General Public License v3.0
81 stars 10 forks source link

use custom ssh key instead of copying all public keys #4

Open seriousm4x opened 1 year ago

seriousm4x commented 1 year ago

Problem: SSH will fail if there is no public key with default name.

debug1: Trying private key: /home/max/.ssh/id_rsa
debug1: Trying private key: /home/max/.ssh/id_ecdsa
debug1: Trying private key: /home/max/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/max/.ssh/id_ed25519
debug1: Trying private key: /home/max/.ssh/id_ed25519_sk
debug1: Trying private key: /home/max/.ssh/id_xmss
debug1: Trying private key: /home/max/.ssh/id_dsa

Explaination: All public ssh keys are copied to the vm on start and VmChamp will try to connect to the vm. If the user doesn't have one of the default keyfile names, the connection will fail because ssh doesn't know which key to use. For example my .ssh dir looks like this:

~/r/VmChamp ❯❯❯ tree ~/.ssh
/home/max/.ssh
├── arbeit
│   ├── config
│   ├── id_1
│   ├── id_1.pub
├── config
├── home
│   ├── config
│   ├── id_1
│   ├── id_1.pub
└── known_hosts

There is none of the default names and connection fails.

Solution: It would be best to create a seperate ssh key somewhere at ~/.config/VmChamp/id_rsa and pass that to the ssh connection to use.

wubbl0rz commented 1 year ago

it copies only the public keys https://github.com/wubbl0rz/VmChamp/blob/master/IsoImager.cs#L13

seriousm4x commented 1 year ago

Ah yes, sorry. It only copies public keys.

Still, the root of the issue remains the same.