Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to use virt-manager to manage my libvirt/kvm virtual machines running on a remote host, but the method I use to ssh into that host it a bit complicated. I need to use custom ports along with agent forwarding with multiple hops. For example, to ssh into that KVM box I use a default identify cert and do this command:

ssh -At -p 4188 www.example.com ssh -At -p 8854 virt-host.internals.int

The dialog for Virtmanager remote connections seems fairly primitive and I was wondering if there is a workaround?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I think you've got two problems.

1) setting up a single ssh connection that goes through the bastion host.

This is basically the same problem as How do I do Multihop SCP transfers? so go read that first.

2) now that you know how to deal with it on the command line more transparently, you need to set it so that it happens without the CLI options.

Set up a ~/.ssh/config file for the user that does the ssh'ing. (Almost?) anything that you can specify on the ssh command line, you can specify in the config file.

For this you would want something along the lines of:

host www.example.com
    port 4188
    forwardagent yes
host virt-host.internals.int
    proxycommand ssh www.example.com nc virt-host.internals.int 8854 

I haven't tested this so the syntax may be off, but it should get you going in the right direction.

Note that it assumes that you can resolve the name virt-host.internals.int from the original client machine. This may not be the case (internal dns only), in which case you will have to kludge it somehow (e.g. /etc/hosts, using ip instead of hostname, etc).

share|improve this answer
I found that the new versions of ssh have nc built in and so my ProxyCommand needed to be ProxyCommand ssh -p 2188 www.example.com -W virt-hosts.internals.int:8854. I would also add that ssh is smart enough to not try to resolve the internal hostname until after it executes the proxy command. Gotta love SSH. –  hdave Apr 30 '13 at 20:44
It's also fortunate that virt-manager runs ssh as its current user so that these options are honored. –  hdave Apr 30 '13 at 21:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.