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

  • 相关阅读:
    Matlab中如何将(自定义)函数作为参数传递给另一个函数
    字幕文件 WebVTT 与 srt 之间的互相转化
    MathType 常用快捷键
    如何解决mathpage.dll或MathType.dll文件找不到问题
    Accelerating Matlab
    VR 相关专业词汇
    Computer Graphics Research Software
    C 和 C++ 混合代码 cmath编译出错
    CG&CAD resource
    Python 面向对象编程——初见
  • 原文地址:https://www.cnblogs.com/jevan/p/3159086.html
Copyright © 2011-2022 走看看