【发布时间】:2016-07-25 03:44:56
【问题描述】:
我编写了一个强制命令脚本,必须通过 ssh 为每个 git 命令执行该脚本。所以,我在服务器端的 /.ssh/authorized_keys 中添加了这一行:
command="/bin/wrapper.sh",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa....
然后我将 wrapper.sh 文件放在 bin 文件夹中,代码如下:
#!/bin/sh
echo -n "Execute the git command? (y/n)?"
read answer
if echo "$answer" | grep -iq "^y" ;then
exec git-shell -c "$SSH_ORIGINAL_COMMAND"
else
echo Goodbye
fi
所以,当我在客户端启动任何 git 命令时,例如 git push origin master,我会收到以下错误:
fatal: protocol error: bad line length character: Exec
我该如何解决?我注意到一个 not git 命令,例如:
ssh User@myhost ls
脚本运行正常。
【问题讨论】: