Skip to content

Instantly share code, notes, and snippets.

@ovc
Forked from h4de5/wsl-ssh-pageant.md
Created December 13, 2019 06:43
Show Gist options
  • Save ovc/c995092bd03d0539dba4fff196c1ade0 to your computer and use it in GitHub Desktop.
Save ovc/c995092bd03d0539dba4fff196c1ade0 to your computer and use it in GitHub Desktop.

Revisions

  1. @h4de5 h4de5 renamed this gist Nov 30, 2017. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions wsl-ssh-pageant.sh → wsl-ssh-pageant.md
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,33 @@
    # prepare on windows cmd
    # see: https://github.com/benpye/wsl-ssh-pageant
    see: https://github.com/benpye/wsl-ssh-pageant

    ```shell
    mkdir workspace
    cd workspace
    git clone [email protected]:benpye/wsl-ssh-pageant.git
    cd wsl-ssh-pageant
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /out:wsl-ssh-pageant.exe Program.cs
    ```

    # prepare bash on wsl
    #mv /mnt/c/Users/$win_user_dir/workspace/wsl-ssh-pageant/wsl-ssh-pageant.exe ~/
    ```shell
    sudo apt install socat
    ```

    # add to .bashrc
    ```shell
    vi ~/.bashrc
    if [ -f $HOME/wsl-ssh-pageant.sh ]; then
    . $HOME/wsl-ssh-pageant.sh
    fi
    ```

    # create wsl-ssh-pageant.sh file
    ```shell
    vi ~/wsl-ssh-pageant.sh
    ```

    ```shell
    #!/bin/bash
    # set home directory:
    win_user_dir=$USER
    @@ -29,3 +38,4 @@ if [ $? != 0 ] ; then
    fi
    socat UNIX-LISTEN:/tmp/wsl-ssh-pageant.socket,unlink-close,unlink-early,fork TCP4:127.0.0.1:13000 &
    export SSH_AUTH_SOCK=/tmp/wsl-ssh-pageant.socket
    ```
  2. @h4de5 h4de5 created this gist Nov 30, 2017.
    31 changes: 31 additions & 0 deletions wsl-ssh-pageant.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # prepare on windows cmd
    # see: https://github.com/benpye/wsl-ssh-pageant
    mkdir workspace
    cd workspace
    git clone [email protected]:benpye/wsl-ssh-pageant.git
    cd wsl-ssh-pageant
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /out:wsl-ssh-pageant.exe Program.cs

    # prepare bash on wsl
    #mv /mnt/c/Users/$win_user_dir/workspace/wsl-ssh-pageant/wsl-ssh-pageant.exe ~/
    sudo apt install socat

    # add to .bashrc
    vi ~/.bashrc
    if [ -f $HOME/wsl-ssh-pageant.sh ]; then
    . $HOME/wsl-ssh-pageant.sh
    fi

    # create wsl-ssh-pageant.sh file
    vi ~/wsl-ssh-pageant.sh

    #!/bin/bash
    # set home directory:
    win_user_dir=$USER
    # check if wsl-ssh-pageant is already running
    pgrep -l wsl-ssh-pageant
    if [ $? != 0 ] ; then
    /mnt/c/Users/$win_user_dir/workspace/wsl-ssh-pageant/wsl-ssh-pageant.exe &
    fi
    socat UNIX-LISTEN:/tmp/wsl-ssh-pageant.socket,unlink-close,unlink-early,fork TCP4:127.0.0.1:13000 &
    export SSH_AUTH_SOCK=/tmp/wsl-ssh-pageant.socket