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 <hui.zhang@citrix.com>
This commit is contained in:
Hui Zhang 2016-02-15 16:47:49 +08:00
parent 784804c8d8
commit c5d9445684

View File

@ -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)