LoginSignup
0
0

More than 5 years have passed since last update.

# fish で ssh-pageant する

Posted at

fish で ssh-pageant する

  • Cygwin の ssh-pageant.exe の出力は bash 用
  • そのまま eval (ssh-pageant -r -a "tmp/.ssh-pageant-$USERNAME") してもダメ
  • fish の set -gx ... するように ssh-pageant の出力をフィルタする

ssh-pageant の出力内容

  • ssh-pageant のオプション
    • -r : 既に SOCKET があれば使いまわす(新しく作らない)
    • -a : 指定パスに SOCKET を作る
  • ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME"
SSH_AUTH_SOCK='/tmp/.ssh-pageant-hogefuge'; export SSH_AUTH_SOCK;
SSH_PAGEANT_PID=1234; export SSH_PAGEANT_PID;
echo ssh-pageant pid 1234;

期待する出力内容

set -gx SSH_AUTH_SOCK '/tmp/.ssh-pageant-hogefuge';
set -gx SSH_PAGEANT_PID 1234;

~/.config/fish/functions/invoke-ssh-pageant.fish

function invoke-ssh-pageant
        eval (ssh-pageant.exe -r -a "/tmp/.ssh-pageant-$USERNAME" \
        | gawk -f ~/.config/fish/functions/ssh-pageant.awk)
end

~/.config/fish/functions/ssh-pageant.awk

#!/usr/bin/gawk
/SSH_AUTH_SOCK/ {
        split($0, a, "[;=]")
        print "set -gx SSH_AUTH_SOCK " a[2] ";"
}
/SSH_PAGEANT_PID/ {
        split($0, a, "[;=]")
        print "set -gx SSH_PAGEANT_PID " a[2] ";"
}

~/.config/fish/functions/config.fish

  • 適当な箇所で invoke-ssh-pageant を呼ぶ
invoke-ssh-pageant
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0