質問するログイン新規登録

質問編集履歴

1

試行コードを追記致しました。

2019/10/01 11:10

投稿

ctk
ctk

スコア31

title CHANGED
File without changes
body CHANGED
@@ -10,4 +10,44 @@
10
10
  そこで、RSA2048ビットでSSH接続する方法をご存知の方がいらっしゃいましたら、
11
11
  ご教示頂けないでしょうか。
12
12
 
13
- 以上です、よろしくお願い致します。
13
+ 以上です、よろしくお願い致します。
14
+
15
+
16
+ Dim sIPAddress As String
17
+ Dim sUser As String
18
+ Dim sPassword As String
19
+ Dim sCommand As String
20
+
21
+ Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
22
+
23
+ sIPAddress = IPadressText.Text
24
+ sUser = UserText.Text
25
+ sPassword = PasswordText.Text
26
+ sCommand = CommandText.Text
27
+
28
+ Dim connInfo As New Renci.SshNet.PasswordConnectionInfo(sIPAddress,
29
+ sUser,
30
+ sPassword)
31
+
32
+ Using client As New Renci.SshNet.SshClient(connInfo)
33
+
34
+ client.Connect()
35
+
36
+ Dim cmd As Renci.SshNet.SshCommand
37
+ Dim result As String
38
+ Dim result2 As String
39
+
40
+ cmd = client.CreateCommand(sCommand)
41
+ cmd.CommandTimeout = TimeSpan.FromSeconds(10)
42
+ result = cmd.Execute
43
+ result2 = cmd.Error
44
+ TextBox1.Text = cmd.ExitStatus
45
+
46
+ If Not String.IsNullOrEmpty(result2) Then
47
+ TextBox1.Text = result2
48
+ End If
49
+
50
+ TextBox1.Text = result
51
+ client.Disconnect()
52
+ End Using
53
+ End Sub