标签: remote-server

MSBuild的.检查是否已安装Windows服务

我是msbuild的新手,目前我正在尝试创建将我的C#windows服务部署到远程测试服务器的msbuild脚本.

我正在考虑使用sc.exe实用程序来实现此目的.阅读它我没有找到一种方法来检查Windows服务是否安装在远程服务器上.如果安装了该服务,那么我需要停止它并更新必要的文件,否则我需要注册该服务.

PS对于发布版本,我计划使用WiX创建MSI包.

deployment msbuild windows-services remote-server

4
推荐指数
1
解决办法
3166
查看次数

从 Invoke-Command 返回的无关数据

我正在使用 PowerShell 从远程服务器列表收集数据,然后将其转换为 JSON 对象。一切工作正常,但我得到了一些我似乎无法排除的非常奇怪的输出。

我尝试过管道传输Invoke-Command结果并排除属性。我还尝试从返回的哈希文件中手动删除这些项目,但我似乎无法让它们消失。

我缺少什么?

编辑:

为了找出问题所在,这里有一个简化但仍然损坏的脚本:

$returnedServer = @{}
$pass = cat "C:\...\securestring.txt" | convertto-securestring
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "UserName",$pass
$s = @("xx.xxx.xxx.xxx","xx.xxx.xxx.xxx") 


foreach($server in $s)
{
    $returnedServer.$server += ,(Invoke-Command -ComputerName $server -ScriptBlock 
{
1
}-credential $mycred | select -ExcludeProperty PSComputerName,RunSpaceID,PSShowComputerName) 

$returnedServer| ConvertTo-Json
Run Code Online (Sandbox Code Playgroud)

哪个输出:

{
"xx.xxx.xxx.xxx":  [
                       {
                           "value":  1,
                           "PSComputerName":  "xx.xxx.xxx.xxx",
                           "RunspaceId":  "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                           "PSShowComputerName":  xxxx
                       }
                   ],
"xx.xxx.xxx.xxx":  [
                       {
                           "value":  1,
                           "PSComputerName":  "xx.xxx.xxx.xxx",
                           "RunspaceId":  "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"",
                           "PSShowComputerName":  xxxx
                       }
                   ]
}
Run Code Online (Sandbox Code Playgroud)

powershell json remote-server invoke-command

4
推荐指数
1
解决办法
4432
查看次数

PyCharm 远程解释器:无法执行 Docker 的 Python 二进制文件

我已将 PyCharm 配置为定位 Docker 容器中的 Python 二进制文件,但收到此错误:

Couldn't refresh skeletons for remote interpreter
failed to run generator3.py for docker://app:latest//usr/local/python/bin/python, exit code 126, stderr: ----- /usr/local/python/bin/python: /usr/local/python/bin/python: cannot execute binary file -----
Run Code Online (Sandbox Code Playgroud)

在使用 Python 3.4.3 的虚拟机中运行 PyCharm 5.0.4 和 Docker 1.10.0。

这是我的 PyCharm 远程解释器设置: 在此输入图像描述

保存这些设置会出现Non-zero exit code.上述错误。

python remote-debugging remote-server pycharm docker

4
推荐指数
1
解决办法
4197
查看次数

用 Python 模拟远程主机

我正在使用 paramiko 编写一些函数来执行命令并在远程主机上创建文件。我想为他们编写一些单元测试,但我不知道实现这一目标的最简单方法是什么?这是我设想的代码示例大纲:

import os
import paramiko
import pytest

def my_function(hostname, relpath='.', **kwargs):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(hostname, **kwargs)
    sftp = ssh.open_sftp()
    sftp.chdir(relpath)
    stdin, stdout, stderr = ssh.exec_command("echo hallo > test.txt")

@pytest.fixture("module")
def mock_remote_host():
    # start a remote host here with a local test path
    try:
        yield hostname, testpath, {"username":"bob", "password":"1234"}
    finally:
        # delete the test path
        # close the remote host

def test_my_function(mock_remote_host):
    hostname, dirpath, kwargs = mock_remote_host
    my_function(hostname, **kwargs)
    filepath = os.path.join(dirpath, 'test.txt')
    assert os.path.exists(filepath)
Run Code Online (Sandbox Code Playgroud)

看过 paramiko …

python unit-testing mocking remote-server paramiko

4
推荐指数
2
解决办法
6274
查看次数

如何将Atom Editor与远程服务器连接?

我尝试在这里查看其他有类似问题的问题,但不幸的是我无法解决这个问题。

对于一些基本的背景信息,我目前在实验室中使用 PC,并且该实验室在机构的某处设有 GPU 服务器。我正在尝试将 Atom 编辑器连接到远程主机。我的电脑使用Windows 10,远程服务器是Ubuntu 16.04。

我看过远程原子指南,但由于某种原因“启动服务器”选项不起作用。我也尝试按照这个答案所述进行操作,但不幸的是我没有sudo权限。

还有其他方法可以远程连接 Atom 吗?谢谢。

remote-server atom-editor

4
推荐指数
1
解决办法
8904
查看次数

从 SSH 会话中分离命令

我需要通过 SSH 会话在服务器上运行命令并关闭会话而不终止服务器上的进程。如何才能正确实施这一点。

服务器和客户端都是linux系统。

请注意,我无法在服务器上安装其他软件。

ssh process sh remote-server

4
推荐指数
1
解决办法
2351
查看次数

错误:“docker context create”正好需要 1 个参数

我正在尝试通过 Docker 上下文使用 docker-compose 部署应用程序。我正在使用本指南:https : //www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/

当我尝试创建上下文时,问题就出现了。例如: docker context create test --docker "host=ssh://user@remotehost" 我明白了:

“docker context create”正好需要 1 个参数。请参阅“docker 上下文创建 --help”。

这只发生在 Windows WSL 上,在 Linux 上它可以完美运行。

我正在使用启用了实验功能的docker 19.03.8

remote-server docker docker-compose windows-subsystem-for-linux docker-desktop

4
推荐指数
2
解决办法
1027
查看次数

将 Python 连接到远程 SQL Server

我正在尝试将 Python 连接到我们的远程 SQL Server,但我没有得到它。以下是我使用的代码。

 server = 'server,1433' 
 database = 'db' 
 username = 'username' 
 password = 'pw' 
 cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
 cursor = cnxn.cursor()
 cursor.execute('SELECT top 1 * FROM db.dbo.t_location')
 for row in cursor:
     print(row)
Run Code Online (Sandbox Code Playgroud)

我们有 2 台服务器。一种是数据库服务器,但我使用连接到数据库服务器的 SQL 应用程序服务器。这是我收到的错误。我尝试了一个星期,但我不确定我在这里错过了什么。任何帮助,将不胜感激

操作错误: ('08001', '[08001] [Microsoft][适用于 SQL Server 的 ODBC 驱动程序 17]TCP 提供程序: 没有已知的此类主机。\r\n (11001) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server 驱动程序 17]登录超时已过期 (0);[08001] [Microsoft][SQL Server ODBC 驱动程序 17]建立与 SQL Server 的连接时出现网络相关或实例特定的错误。未找到服务器或无法访问。请检查实例名称是否正确以及 SQL Server 是否配置为允许远程连接。有关详细信息,请参阅 SQL Server 联机丛书。(11001)') …

python sql-server pyodbc remote-server

4
推荐指数
1
解决办法
1万
查看次数

无法建立与“主机名”的连接。(VSCode 中的远程 SSH 问题)(CentOS7)

[解决了!!]

\n
    \n
  • 服务器操作系统: CentOS Linux 7
  • \n
  • VSCode 版本(本地): 1.59.1
  • \n
\n

我通过 ssh 连接到我的服务器

\n
ssh ...@ln01.twcc.ai\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试通过本地打开 VSCode,并使用Remote-SSH -> 连接到 SSH -> 输入 ...@ln01.twcc.ai

\n

然后得到无法建立与“@ln01.twcc.ai”的连接。错误块\n输出如下

\n
[11:37:51.572] Log Level: 2\n[11:37:51.574] remote-ssh@0.65.7\n[11:37:51.574] win32 x64\n[11:37:51.575] SSH Resolver called for "ssh-remote+...", attempt 1\n[11:37:51.575] "remote.SSH.useLocalServer": false\n[11:37:51.575] "remote.SSH.showLoginTerminal": false\n[11:37:51.575] "remote.SSH.remotePlatform": {}\n[11:37:51.575] "remote.SSH.path": undefined\n[11:37:51.575] "remote.SSH.configFile": undefined\n[11:37:51.575] "remote.SSH.useFlock": true\n[11:37:51.576] "remote.SSH.lockfilesInTmp": false\n[11:37:51.576] "remote.SSH.localServerDownload": auto\n[11:37:51.576] "remote.SSH.remoteServerListenOnSocket": false\n[11:37:51.576] "remote.SSH.showLoginTerminal": false\n[11:37:51.576] "remote.SSH.defaultExtensions": []\n[11:37:51.576] "remote.SSH.loglevel": 2\n[11:37:51.576] SSH Resolver called for host: ssh ...@ln01.twcc.ai\n[11:37:51.576] Setting …
Run Code Online (Sandbox Code Playgroud)

ssh remote-server visual-studio-code

4
推荐指数
2
解决办法
6万
查看次数

无法推送到远程GIT存储库 - "[...]似乎不是一个git存储库"

我在我的服务器上使用以下相应文件夹(我的子域的根目录git.mydomain.com)设置了我的GIT存储库:

mkdir foo.git
cd foo.git
git init --bare --shared
Run Code Online (Sandbox Code Playgroud)

这将使URL可以使用存储库git.mydomain.com/foo.git.

在我的客户端上,尝试使用以下命令将提交的文件推送到服务器:mkdir foo

cd foo
git init
git remote add foo myUser@git.mydomain.com:foo.git
git add readme.txt
git commit -m "foo"
git push foo master
.. entering user password ..
Run Code Online (Sandbox Code Playgroud)

只有结果:

fatal: 'foo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

但是,遵循一系列不同的指南,我似乎无法解决此问题.任何建议都将受到高度赞赏,请记住,我对GIT非常环保.

git version-control client remote-server

3
推荐指数
1
解决办法
3415
查看次数