Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate new API endpoints to copy data #9

Open
lnxbil opened this issue Jan 31, 2019 · 2 comments
Open

Integrate new API endpoints to copy data #9

lnxbil opened this issue Jan 31, 2019 · 2 comments

Comments

@lnxbil
Copy link
Owner

lnxbil commented Jan 31, 2019

via the new API endpoints, we can now finally copy files and execute commands:

root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/file-write -content "file" -file "/root/test"

root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command id
┌─────┬───────┐
│ key │ value │
├─────┼───────┤
│ pid │ 1708  │
└─────┴───────┘

root@proxmox ~ > pvesh get /nodes/proxmox/qemu/109/agent/exec-status -pid 1708
┌──────────┬────────────────────────────────────────┐
│ key      │ value                                  │
├──────────┼────────────────────────────────────────┤
│ exitcode │ 0                                      │
├──────────┼────────────────────────────────────────┤
│ exited   │ 1                                      │
├──────────┼────────────────────────────────────────┤
│ out-data │ uid=0(root) gid=0(root) groups=0(root) │
└──────────┴────────────────────────────────────────┘

This should be very useful in copying the initial SSH key over to the guest.

@lnxbil
Copy link
Owner Author

lnxbil commented Jan 31, 2019

It works for the RancherOS Integration in #8 as follows (direct API calls from the PVE host itself just for testing):

$ pvesh create /nodes/proxmox/qemu/109/agent/exec -command mkdir -command "-p" -command /home/rancher/.ssh
$ pvesh create /nodes/proxmox/qemu/109/agent/file-write -content "ssh-rsa AAAAB<further-key>" -file "/home/rancher/.ssh/authorized_keys"
$ pvesh create /nodes/proxmox/qemu/109/agent/exec -command chmod -command 600 --command -command /home/rancher/.ssh/authorized_keys
$ pvesh create /nodes/proxmox/qemu/109/agent/exec -command chmod -command 600 -command /home/rancher/.ssh/authorized_keys

Afterwards I'm able to login:

$ ssh -i $HOME/.docker/machine/machines/docker-rancher/id_rsa rancher@192.168.1.135 hostname
rancher

Now we could call the endpoints in GO and setup directly though the qemu-guest-agent.

@BitStab
Copy link

BitStab commented Apr 9, 2020

Hi,

we are encountering exactly this problem in #8
Error creating machine: Error in driver during machine creation: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

if we launch the commands of your latest comment, the SSH keys are copied and it all works as expected and we are able to login.
BUT:
An automatic provisioning/deployment of a new requested machine is not possible without those manual commands.
Did you already modify the driver so it works throught qemu-guest-agent? We can't get any positive results with the latest release (V3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants