Bonjour,

J'aimerai automatiser la connexion à un serveur en SSH en utilisant Putty. La connexion se déroule en fournissant un certificat (.ppk) et en indiquant une passphrase.
J'aimerai envoyer à Putty directement la passphrase pour éviter que l'utilisateur le fasse.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// start the putty session
ProcessStartInfo startInfo = new ProcessStartInfo("putty.exe");
startInfo.Arguments = " -load monserver.com";
startInfo.UseShellExecute = false;
startInfo.ErrorDialog = false;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
 
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
StreamWriter inputWriter = process.StandardInput;
inputWriter.AutoFlush = true;
inputWriter.WriteLine("Ma_passphrase_ici");
Le problème, c'est que le texte "Ma_passphrase_ici" n'est pas envoyé à putty, dans la fenetre il n'écrit rien. (idem en validant à la main)

Comment faire pour écrire automatiquement la passphrase dans putty ?

Merci.