Skip to content

Instantly share code, notes, and snippets.

@cyberdelia
Last active March 23, 2023 23:03
Show Gist options
  • Select an option

  • Save cyberdelia/91f7ec06a745310cec0615820ead8652 to your computer and use it in GitHub Desktop.

Select an option

Save cyberdelia/91f7ec06a745310cec0615820ead8652 to your computer and use it in GitHub Desktop.

Revisions

  1. cyberdelia revised this gist Feb 3, 2023. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions sshd.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +0,0 @@
    # To re-enable the built-in ssh-agent.
    launchctl unload com.lapanthere.secure-agent
    sudo launchctl enable system/com.openssh.ssh-agent
  2. cyberdelia revised this gist Dec 27, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions autocompletion.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    /usr/local/bin/secure-agent --generate-completion-script fish
    /usr/local/bin/secure-agent --generate-completion-script bash
    /usr/local/bin/secure-agent --generate-completion-script zsh
    secure-agent --generate-completion-script fish
    secure-agent --generate-completion-script bash
    secure-agent --generate-completion-script zsh
  3. cyberdelia revised this gist Dec 27, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions autocompletion.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    /usr/local/bin/secure-agent --generate-completion-script fish
    /usr/local/bin/secure-agent --generate-completion-script bash
    /usr/local/bin/secure-agent --generate-completion-script zsh
  4. cyberdelia revised this gist Jul 19, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sshd.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # To re-enable the built-in ssh-agent.
    launchctl unload com.lapanthere.secure-agent
    sudo launchctl enable system/com.openssh.ssh-agent
  5. cyberdelia revised this gist Mar 9, 2020. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions secure-agent.fish
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    function __agent_is_started -d "check if ssh agent is already started"
    if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
    source $SSH_ENV > /dev/null
    if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
    source $SSH_ENV > /dev/null
    end

    if test -z "$SSH_AGENT_PID"
    return 1
    end
    return 1
    end

    ps -p $SSH_AGENT_PID > /dev/null
    return $status
    @@ -27,3 +27,5 @@ function fish_ssh_agent --description "start ssh-agent if not started yet, or us
    __agent_start
    end
    end

    fish_ssh_agent
  6. cyberdelia revised this gist Mar 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion secure-agent.zsh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    function start_ssh_agent() {
    secure-agent daemon | sed 's/^echo/#echo/' >! $ssh_environment
    secure-agent daemon | head -n 2 >! $ssh_environment
    chmod 600 $ssh_environment
    source $ssh_environment > /dev/null
    }
  7. cyberdelia revised this gist Mar 7, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions secure-agent.fish
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,9 @@ function __agent_is_started -d "check if ssh agent is already started"
    source $SSH_ENV > /dev/null
    end

    if test -z "$SSH_AGENT_PID"
    return 1
    end
    if test -z "$SSH_AGENT_PID"
    return 1
    end

    ps -p $SSH_AGENT_PID > /dev/null
    return $status
  8. cyberdelia revised this gist Mar 7, 2020. 1 changed file with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions secure-agent.fish
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    function __agent_is_started -d "check if ssh agent is already started"
    if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
    source $SSH_ENV > /dev/null
    end

    if test -z "$SSH_AGENT_PID"
    return 1
    end

    ps -p $SSH_AGENT_PID > /dev/null
    return $status
    end

    function __agent_start -d "start a new ssh agent"
    secure-agent daemon > $SSH_ENV
    chmod 600 $SSH_ENV
    source $SSH_ENV > /dev/null
    true
    end

    function fish_ssh_agent --description "start ssh-agent if not started yet, or uses already started ssh-agent."
    if test -z "$SSH_ENV"
    set -xg SSH_ENV $HOME/.ssh/environment
    end

    if not __agent_is_started
    __agent_start
    end
    end
  9. cyberdelia revised this gist Mar 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion secure-agent.zsh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    function start_ssh_agent() {
    secure-agent | sed 's/^echo/#echo/' >! $ssh_environment
    secure-agent daemon | sed 's/^echo/#echo/' >! $ssh_environment
    chmod 600 $ssh_environment
    source $ssh_environment > /dev/null
    }
  10. cyberdelia created this gist Mar 7, 2020.
    19 changes: 19 additions & 0 deletions secure-agent.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    function start_ssh_agent() {
    secure-agent | sed 's/^echo/#echo/' >! $ssh_environment
    chmod 600 $ssh_environment
    source $ssh_environment > /dev/null
    }

    ssh_environment="$HOME/.ssh/environment"

    if [[ -f "$ssh_environment" ]]; then
    source $ssh_environment > /dev/null
    ps x | grep secure-agent | grep -q $SSH_AGENT_PID || {
    start_ssh_agent
    }
    else
    start_ssh_agent
    fi

    unset ssh_environment
    unfunction start_ssh_agent