Plink는 sudo의 git 명령 파일에서 작동하지 않습니다.

Plink는 sudo의 git 명령 파일에서 작동하지 않습니다.

git 명령 자동화를 위해 plink.exe를 사용하는데 잘 작동합니다. 하지만 sudo 로그인이 있는 서버에서 이것을 사용해야 합니다.

plink.exe -ssh [email protected] -m commands.txt

내 Commands.txt 파일의 예는 다음과 같습니다.

echo -e "MYPASSWORD\n" | sudo -S -i
cd /home/www/argentium.ru
git checkout HEAD~3

출력은 로그인된 것처럼 보이지만 git은 sudo 로그인 없이 작동하는 것처럼 실행됩니다.

[sudo] password for argentium: fatal: Unable to create '/home/www/argentium.ru/.git/index.lock': Permission denied

도움을 받으면 putty.exe가 제대로 작동합니다.

сentos-7-x86_64-minimal @ 23.11.2016
-bash-4.2$ sudo -i
[sudo] password for argentium:
[root@stilnoeserebro ~]# cd /home/www/argentium.ru
[root@stilnoeserebro argentium.ru]# git checkout HEAD~3
Note: checking out 'HEAD~3'.

답변1

이 명령은 sudo -S -i표준 입력에서 암호와 명령을 읽습니다.

표준 입력 에서는 echo -e "MYPASSWORD\n" | sudo -S -i파이프에서 새 줄을 반환하고 비밀번호를 읽은 후 파일 끝을 반환합니다. 나머지 명령은 일반 셸에서 실행됩니다.

몇 가지 방법이 있습니다. 코딩한 내용에 가장 가까운 것은여기 문서:-

sudo -S -i <<EOF
MYPASSWORD
cd /home/www/argentium.ru
git checkout HEAD~3
EOF

또는 모든 명령을 입력 스트림에 추가할 수 있습니다.

echo -e "MYPASSWORD\ncd /home/www/argentium.ru\ngit checkout HEAD~3" | sudo -S -i

.bashplink

관련 정보