Linux 将windows server连接到unix服务器时出现问题
将web应用程序从windows 2003 server迁移到windows 2012 server 当一部分代码必须登录到linux服务器并在那里执行一些命令时,就会出现问题 代码是Linux 将windows server连接到unix服务器时出现问题,linux,vb.net,iis-8,windows-server-2012-r2,http-status-code-401,Linux,Vb.net,Iis 8,Windows Server 2012 R2,Http Status Code 401,将web应用程序从windows 2003 server迁移到windows 2012 server 当一部分代码必须登录到linux服务器并在那里执行一些命令时,就会出现问题 代码是 sResponse = obj.RunSSH_Resp(anotherObj.Server, My.Settings.UNIX_FUNC_LOGIN.ToString, My.Settings.UNIX_FUNC_PASSWORD.ToString, sCmd, False, 120, "StartTag")
sResponse = obj.RunSSH_Resp(anotherObj.Server,
My.Settings.UNIX_FUNC_LOGIN.ToString,
My.Settings.UNIX_FUNC_PASSWORD.ToString, sCmd, False, 120, "StartTag")
虽然这段代码在旧服务器上运行正常,但我们似乎还没有在新服务器上进行一些配置,这就是为什么windows服务器无法与linux服务器通信的原因
我能够从windows server成功ping linux服务器,但当我试图打开linux驱动器(因为它们是共享的SAMBA驱动器)时,我无法打开它们
编辑:我认为web应用程序IIS管理器中的权限存在一些问题。您能告诉我什么是正确的IIS配置,以使web应用程序能够与linux服务器通信吗
编辑2:以下代码返回
远程服务器返回错误:(401)未经授权
这个问题需要更多的信息。另一个对象是什么类型的对象?那obj呢?您是否已验证可以从新的windows服务器手动登录到linux框?(因为可能是网络/防火墙规则)。错误消息是什么?@GregHNZ我已经编辑了这个问题。我认为这是网络/防火墙规则,请告诉我如何配置它们。
Public Function RunSSH_Resp(ByVal i_sServer As String, ByVal i_sLogin As String, ByVal i_sPassword As String, _
ByVal i_sCommand As String, Optional ByVal i_bEscapeCmd As Boolean = True, _
Optional ByVal i_lTimeout As Long = 20, Optional ByVal i_sStartTag As String = "") As String
Dim oWebRequest As WebRequest
Dim oRequestStream As Stream
Dim oStreamWriter As StreamWriter
Dim oWebResponse As WebResponse
Dim oResponseStream As Stream
Dim oStreamReader As StreamReader
Dim sWebSSHUrl As String = My.Settings.WEBSSH_URL.ToString
Dim sEscapeCmd As String = "y"
If Not i_bEscapeCmd Then sEscapeCmd = "n"
Dim sResponseText As String = ""
Dim sFormData As String
sFormData = "server=" & i_sServer & "&login=" & i_sLogin & "&password=" & i_sPassword & _
"&command=" & HttpContext.Current.Server.UrlEncode(i_sCommand) & "&timeout=" & i_lTimeout & _
"&starttag=" & HttpContext.Current.Server.UrlEncode(i_sStartTag) & "&escapecmd=" & sEscapeCmd
' Create a new WebRequest
' if working in a separate environment, then call the server by name, otherwise localhost (this should not be done to prevent login and password passing in network)
Try
oWebRequest = WebRequest.Create(sWebSSHUrl)
oWebRequest.Method = "POST"
oWebRequest.ContentLength = sFormData.Length
oWebRequest.ContentType = "application/x-www-form-urlencoded"
oWebRequest.Timeout = i_lTimeout * 1000
'oWebRequest.UseDefaultCredentials = True
'oWebRequest.PreAuthenticate = True
'oWebRequest.Credentials = CredentialCache.DefaultCredentials
oRequestStream = oWebRequest.GetRequestStream()
'send the request
oStreamWriter = New StreamWriter(oRequestStream)
oStreamWriter.Write(sFormData)
oStreamWriter.Flush()
oStreamWriter.Close()
oRequestStream.Close()
' Get the response
oWebResponse = oWebRequest.GetResponse()
oResponseStream = oWebResponse.GetResponseStream()
oStreamReader = New StreamReader(oResponseStream)
sResponseText = oStreamReader.ReadToEnd()
oStreamReader.Close()
oResponseStream.Close()
oWebResponse.Close()
Catch ex As Exception
oWebRequest = Nothing
oRequestStream = Nothing
oStreamWriter = Nothing
oWebResponse = Nothing
oResponseStream = Nothing
oStreamReader = Nothing
Return ex.Message
End Try
End Function