From c5d94456844bef8b405552a1e3b6880666c08b83 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Mon, 15 Feb 2016 16:47:49 +0800 Subject: [PATCH] CP-13124: Use SSH private key for docker guest VM authentication. 1. Specify the key file location and name. 2. Update of the file name of docker command. Signed-off-by: Hui Zhang --- XenAdmin/TabPages/GeneralTabPage.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/XenAdmin/TabPages/GeneralTabPage.cs b/XenAdmin/TabPages/GeneralTabPage.cs index 33749c6d0..b2c66a63e 100644 --- a/XenAdmin/TabPages/GeneralTabPage.cs +++ b/XenAdmin/TabPages/GeneralTabPage.cs @@ -1822,12 +1822,21 @@ namespace XenAdmin.TabPages try { //Write docker command to a temp file. - string cmdFile = Path.Combine(Path.GetTempPath(), "cmdXSContainer.txt"); + string cmdFile = Path.Combine(Path.GetTempPath(), "ContainerManagementCommand.txt"); File.WriteAllText(cmdFile, command); //Invoke Putty, SSH to VM and execute docker command. var puttyPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "putty.exe"); - var startInfo = new ProcessStartInfo(puttyPath, "-m " + cmdFile + " -t " + ipAddr); + string args = "-m " + cmdFile + " -t " + ipAddr; + + //Specify the key for SSH connection. + var keyFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "ContainerManagement.ppk"); + if (File.Exists(keyFile)) + { + args = args + " -i " + keyFile; + } + var startInfo = new ProcessStartInfo(puttyPath, args); + Process.Start(startInfo); } catch (Exception ex)