我尝试从另一个服务器1到服务器2执行ssh,然后执行从服务器1到服务器2的git拉取。
因此,在服务器1上,我运行以下命令:
ssh root@server2 'cd /root/.example; git pull origin master'
但这给了我一个错误
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
它能够ssh是因为当我执行ls命令时,我看到了/root
我正在尝试从服务器1到服务器2执行ssh,并从服务器1执行git pull到服务器2。
因此,在服务器1上,我运行以下命令:
ssh root@server2 'cd /root/.example; git pull origin master'
但这给了我一个错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
它能够执行ssh,因为当我执行ls (ssh root
我的批处理文件代码需要使用SSH在多个服务器上运行一些shell命令。为此,我使用了来自for循环的Plink。
我不希望使用-pw将纯文本密码输入到Plink命令行。相反,出于安全考虑,我想对我的密码使用密码加密,并将密码存储到单独的文本文件中。
我试过使用sshpass,但这在批处理中不受支持。由于运行代码的请求将在多个服务器上运行,所以我不希望为每个服务器生成SSH密钥对,因为在环境中无法为数百个服务器生成SSH密钥对。
@echo off
for /f "delims=" %%a in (path\to\servers.txt) DO (
plink -v -s