zoukankan      html  css  js  c++  java
  • 搞定:Enter passphrase for key提示

    使用ssh-genkey生成公用key,但是自己使用时会多次提示,Enter passphrase for key,这儿给出如何解决。

    在${HOME}/.bashrc中增加如下代码:

    1. alias auto_passphrase=auto_passphrase
    2.    
    3.    
    4. SSH_ENV=~/.ssh/environment
    5. # start the ssh-agent
    6. function start_agent {
    7.    echo "Initializing new SSH agent…"
    8.    # spawn ssh-agent
    9.    ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
    10.    echo succeeded
    11.    chmod 600 "$SSH_ENV"
    12.    . "$SSH_ENV" > /dev/null
    13.    ssh-add
    14. }
    15.    
    16. # test for identities
    17. function test_identities {
    18.    # test whether standard identities have been added to the agent already
    19.    ssh-add -l | grep "The agent has no identities" > /dev/null
    20.    if [ $? -eq 0 ]; then
    21.    ssh-add
    22.       # $SSH_AUTH_SOCK broken so we start a new proper agent
    23.       if [ $? -eq 2 ];then
    24.       start_agent
    25.       fi
    26.    fi
    27. }
    28.    
    29. #auto_ssh
    30. function auto_passphrase {
    31.    # check for running ssh-agent with proper $SSH_AGENT_PID
    32.    if [ -n "$SSH_AGENT_PID" ]; then
    33.       ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
    34.       if [ $? -eq 0 ]; then
    35.       test_identities
    36.       fi
    37.    # if $SSH_AGENT_PID is not properly set, we might be able to load one from
    38.    # $SSH_ENV
    39.    else
    40.       if [ -f "$SSH_ENV" ]; then
    41.       . "$SSH_ENV" > /dev/null
    42.       fi
    43.       ps -ef | grep "$SSH_AGENT_PID" | grep -v grep | grep ssh-agent > /dev/null
    44.       if [ $? -eq 0 ]; then
    45.          test_identities
    46.       else
    47.          start_agent
    48.       fi
    49.    fi
    50. }

     

     

    原始文章:http://wooley.me/archives/589

  • 相关阅读:
    1061 Dating (20 分)
    1112 Stucked Keyboard (20 分)
    1077 Kuchiguse (20 分)
    1065 A+B and C (64bit) (20 分)
    1046 Shortest Distance (20 分)
    1124 Raffle for Weibo Followers (20 分)
    1036 Boys vs Girls (25 分)
    1113 Integer Set Partition (25 分)
    f开头的
    g开头的
  • 原文地址:https://www.cnblogs.com/jevan/p/3159086.html
Copyright © 2011-2022 走看看