如何使用python克隆带有密码短语的SSH密钥?

如何使用python克隆带有密码短语的SSH密钥?,python,gitlab,subprocess,pipe,Python,Gitlab,Subprocess,Pipe,我是python新手,我想用密码短语git克隆SSH密钥。通过提及这一点,我尝试如下: 从子流程导入Popen,管道 密码='password@' proc=Popen(['git','clone','git@gitlab.com:gitlab.com/julie/board.git'],stdin=PIPE) 过程通信(密码) 这就是它给出的输出: Traceback (most recent call last): File "C:\Users\dell\eclipse-workspa

我是python新手,我想用密码短语git克隆SSH密钥。通过提及这一点,我尝试如下:

从子流程导入Popen,管道
密码='password@'
proc=Popen(['git','clone','git@gitlab.com:gitlab.com/julie/board.git'],stdin=PIPE)
过程通信(密码)
这就是它给出的输出:

Traceback (most recent call last):
  File "C:\Users\dell\eclipse-workspace\GitTrial\Git\__init__.py", line 123, in <module>
    proc.communicate(password)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1009, in communicate
    self._stdin_write(input)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 958, in _stdin_write
    self.stdin.write(input)
TypeError: a bytes-like object is required, not 'str'
Cloning into 'board'...
Permission denied, please try again.
Permission denied, please try again.
git@gitlab.com: Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
回溯(最近一次呼叫最后一次):
文件“C:\Users\dell\eclipse workspace\GitTrial\Git\\uuuuu init\uuuuuu.py”,第123行,在
过程通信(密码)
文件“C:\Users\dell\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py”,第1009行,在“通信”中
自写入(输入)
文件“C:\Users\dell\AppData\Local\Programs\Python 38-32\lib\subprocess.py”,第958行,在写入时
self.stdin.write(输入)
TypeError:需要类似字节的对象,而不是“str”
克隆到“board”。。。
权限被拒绝,请重试。
权限被拒绝,请重试。
git@gitlab.com:权限被拒绝(公钥、密码)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并且存储库存在。
我正在使用Windows10。 有人能帮我解决这个问题吗?

日志显示:

...
    proc.communicate(password)
...
TypeError: a bytes-like object is required, not 'str'
密码应为字节而不是字符串:

password=b'password@'

和abt权限被拒绝(公钥、密码)。致命:无法从远程存储库读取。当您转到控制台并手动执行时会发生什么情况<代码>git克隆git@gitlab.com:gitlab.com/julie/board.git这不应该是
git@gitlab.com:julie/board.git
?指向项目的SSHURL似乎是错误的。我认为这是正确的,因为我可以使用GitBash进行克隆,但无法使用python。你能告诉我在哪里可以提到我要克隆的位置吗?那么,脚本的工作状态是什么,或者它仍然会产生
权限被拒绝
错误?