Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Run it with: (You may add it to your ~/.bashrc)
- ( nohup setsid win32_ssh_agent_bridge.sh 2> >(nohup setsid tee /tmp/openssh-ssh-agent.err.log > /dev/null 2>&1) > /tmp/openssh-ssh-agent.log & )
- # ---- win32_ssh_agent_bridge.sh starts ----
- #!/bin/bash
- PIDFILE=/var/run/openssh-ssh-agent.$(awk '/btime/{print $2}' /proc/stat).pid
- if [ -f $PIDFILE ]
- then
- PID=$(cat $PIDFILE)
- ps -p $PID > /dev/null 2>&1
- if [ $? -eq 0 ]
- then
- echo "[ssh-agent bridge already running]"
- exit 1
- else
- ## Process not found assume not running
- echo $$ > $PIDFILE
- if [ $? -ne 0 ]
- then
- echo "[ssh-agent bridge] Could not create PID file" >&2
- exit 1
- fi
- fi
- else
- echo $$ > $PIDFILE
- if [ $? -ne 0 ]
- then
- echo "[ssh-agent bridge] Could not create PID file" >&2
- exit 1
- fi
- fi
- # Main script ... Do work here
- echo [ssh-agent bridge start]
- unlink /tmp/openssh-ssh-agent > /dev/null 2>&1
- PLINK_PATH=$(which -a plink | tail -1)
- ln -sf "$PLINK_PATH" /usr/local/bin/plink_for_agent
- socat UNIX-LISTEN:/tmp/openssh-ssh-agent,umask=066,fork EXEC:"/usr/local/bin/plink_for_agent -serial //./pipe/openssh-ssh-agent",pipes
- echo [ssh-agent bridge ended] >&2
- # End
- rm $PIDFILE
Advertisement
Add Comment
Please, Sign In to add comment