Bonjour,
Je souhaite me connecter � un serveur UNIX en SSH et ex�cuter des commandes pour modifier les droits sur des r�pertoires et des fichiers.
Comment-puis je le faire en C# ?
Merci d'avance
Version imprimable
Bonjour,
Je souhaite me connecter � un serveur UNIX en SSH et ex�cuter des commandes pour modifier les droits sur des r�pertoires et des fichiers.
Comment-puis je le faire en C# ?
Merci d'avance
Bonjour !
Si c'est pas d�j� fait, jette un coup d'oeil sur ce topic !
Merci pour la r�ponse mais ce n'ai pas ce que je cherche
J'ai d�j� r�ussi a r�aliser une application qui se connecte a SSH et faire m�me des transfert (SCP)
mais ce que je cherche c'est quoi faire pour changer les droit d'un r�pertoire .... affecter les droit a un r�pertoire
PS: je programme avec visual csharp
salut
je trouve pas de r�ponse sur d�veloppez ces dernier temps
Voila la solution de mon probl�me
vous aurez besoin de la Dll chilkatDotnet2Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; namespace SSH { class droit { public static void Main(string hostname, string name, string pass) { // Important: It is helpful to send the contents of the // ssh.LastErrorText property when requesting support. Chilkat.Ssh ssh = new Chilkat.Ssh(); // Any string automatically begins a fully-functional 30-day trial. bool success; success = ssh.UnlockComponent("Anything for 30-day trial"); if (success != true) { MessageBox.Show(ssh.LastErrorText); return; } // Connect to an SSH server: success = ssh.Connect(hostname,22); if (success != true) { MessageBox.Show(ssh.LastErrorText); return; } // Wait a max of 5 seconds when reading responses.. ssh.IdleTimeoutMs = 5000; // Authenticate using login/password: success = ssh.AuthenticatePw(name, pass); if (success != true) { MessageBox.Show(ssh.LastErrorText); return; } // Open a session channel. (It is possible to have multiple // session channels open simultaneously.) int channelNum; channelNum = ssh.OpenSessionChannel(); if (channelNum < 0) { MessageBox.Show(ssh.LastErrorText); return; } // changer les droit d'un repertoir success = ssh.SendReqExec(channelNum, "chmod 600 /home/utilisateur/.ssh/authorized_keys"); if (success != true) { MessageBox.Show(ssh.LastErrorText); return; } int n; int pollTimeoutMs; pollTimeoutMs = 2000; n = ssh.ChannelReadAndPoll(channelNum, pollTimeoutMs); if (n < 0) { MessageBox.Show(ssh.LastErrorText); return; } // Close the channel: success = ssh.ChannelSendClose(channelNum); if (success != true) { MessageBox.Show(ssh.LastErrorText); return; } success = ssh.ChannelReceiveToClose(channelNum); if (success != true) { MessageBox.Show(ssh.LastErrorText); return; } // Disconnect //ssh.Disconnect(); } } }
Bon courage � tous
Tu as jet� un oeil � cette librairie ?
http://www.tamirgal.com/blog/page/SharpSSH.aspx
Contrairement � Chilkat Ssh, c'est gratuit et open source. C'est un portage en .NET d'une librairie SSH en Java.
La classe SshExec permet d'ex�cuter n'importe quelle commande, comme un chmod, avec un code beaucoup plus simple que Chilkat