How to forward agent with "az ssh arc"

Gabor152 20 Reputation points
2024-11-27T11:35:00.3966667+00:00

Hi,

I have two Ubuntu 22.04 machines connected to Azure using azcmagent: host1 and host2.

I can connect to them separately:

az ssh arc --resource-group ${RG} --name host1
az ssh arc --resource-group ${RG} --name host2

But what I need to do is: connect to host1 with -A and from there connect to host2 - and it doesn't work.

Here's what I tried:

  1. generate keys and config file:
az ssh config  --resource-group ${RG} --name host1 --file ssh_config
az ssh config  --resource-group ${RG} --name host2 --file ssh_config

  1. add the IdentityFile (path in ssh_config) to ssh-agent:
eval `ssh-agent` && ssh-add ...id_rsa
az ssh arc --resource-group ${RG} --name host1 -- -A
# on host1
ssh-add -l
# key is there
ssh host2
... Permission denied (publickey).


On host2 I see this error in the log: The public key is of type ssh-rsa, not a certificate.

I did some research and I tried a couple of things:

  • created two Ubuntu 24.04 machines: same result
  • created two Ubuntu 20.04 machines: same result
  • added -o "PubkeyAcceptedKeyTypes=+******@openssh.com" : same result

I'm sure I'm doing something wrong but I don't know what. Unfortunately the documentation lacks the details: https://learn.microsoft.com/en-us/cli/azure/ssh?view=azure-cli-latest#az-ssh-arc.

Any idea how to do it right?

Azure Arc
Azure Arc
A Microsoft cloud service that enables deployment of Azure services across hybrid and multicloud environments.
525 questions
{count} votes

Accepted answer
  1. SadiqhAhmed-MSFT 49,326 Reputation points Microsoft Employee Moderator
    2024-11-28T10:30:46.23+00:00

    Summarizing from the discussion (above). @Gabor152, Thanks for sharing the info/solution with the community.

    Issue: How to forward agent with "az ssh arc"

    Solution: Steps to make it work:

    • az ssh config --resource-group ${RG} --name host1 --file ssh_config
    • Rename id_rsa.pub-aadcert.pub to id_rsa-cert.pub (check paths in ssh_config file)
    • ssh-add id_rsa - it says "Identity added:...", "Certificate added:..."
    • ssh-add -L shows the certificate
    • az ssh arc --resource-group ${RG} --name host1 -- -A
    • from host1: ssh host2 - works, without any further configuration.

    Background: If the identity file is say XYZ, then the SSH client will look for the certificate in XYZ-cert.pub.

    Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer. They can only accept answers by others, I' have summarized and posted the solution/answer to benefit the community users to find the answers quickly.


    If the response helped, do "Accept Answer" and up-vote it

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Gabor152 20 Reputation points
    2024-11-28T10:22:31.6166667+00:00

    I found it!

    Steps to make it work:

    • az ssh config --resource-group ${RG} --name host1 --file ssh_config
    • Rename id_rsa.pub-aadcert.pub to id_rsa-cert.pub (check paths in ssh_config file)
    • ssh-add id_rsa - it says "Identity added:...", "Certificate added:..."
    • ssh-add -L shows the certificate
    • az ssh arc --resource-group ${RG} --name host1 -- -A
    • from host1: ssh host2 - works, without any further configuration.

    Background: If the identity file is say XYZ, then the SSH client will look for the certificate in XYZ-cert.pub.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.