大网数据广告活动
服务器运维问答

Virtmanager connection via custom SSH command?

· 52CE 我爱测

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 multipl…

问题原文

原帖链接 · Dave · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Dan Pritts · CC BY-SA 4.0

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 between machines? so go read that first.

  1. 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).


Update 2023: You can now use the ProxyJump argument to ssh. It'll automatically tunnel through your bastion host for you. Needs to have a newish version of ssh to work.

If your ssh command supports it, you can simply do something like this instead of the mumbo-jumbo listed above:

host virt-host.internals.int
   ProxyJump www.example.com  

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-04-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。