2017-02-09 27 views
0

我正在與fabric3(https://pypi.python.org/pypi/Fabric3),一個python 3端口的織物一起工作。結構命令不能使用特定的ssh密鑰

,我有以下功能wchich我在本地WIN7使用Git的bash運行:

@roles('production') 
def dir(): 
    env.key_filename = '~/.ssh/deploy' 
    local("git push mysite master") 
    run('pwd') 
    run('ls') 
    code_dir = '/home/deploy/mysite' 
    with cd(code_dir): 
     run('pwd') 
     run('git reset --hard master') 
     run('ls -la') 

輸出:

$ fab dir 
[[email protected]] Executing task 'dir' 
[localhost] local: git push mysite master 
[email protected]'s password: 

當我運行的功能,有人問我輸入密碼。這似乎忽略了關鍵。我如何獲得使用指定鍵的功能?

+0

git push是否提示密碼? – Leon

+0

是的,它看起來如此。 – user61629

+0

'fabric'下執行的'git push'通過一個不受'fabric'管理的獨立連接來連接到遠程主機。 – Leon

回答

0

我將git作爲用戶添加到我的.ssh/config文件中,現在它似乎可以正常工作。

Host deploy 
HostName 198.x.x.x 
User deploy 
PreferredAuthentications publickey 
IdentityFile ~/.ssh/deploy 
IdentitiesOnly yes 

Host 198.x.x.x 
HostName 198.x.x.x 
User git 
IdentityFile ~/.ssh/deploy