SSH 로그인을 자동화하면 응답하지 않는 원격 셸이 제공되고 클라이언트 터미널로 다시 돌아갑니다(오류 없음).

SSH 로그인을 자동화하면 응답하지 않는 원격 셸이 제공되고 클라이언트 터미널로 다시 돌아갑니다(오류 없음).

Ubuntu 14.04 LTS에서 예상되는 도구에 문제가 있습니다. 일부 Sophos UTM 방화벽에 대한 SSH 로그인을 자동화하고 "sudo su -" 및 올바른 비밀번호를 사용하여 바로 내 권한을 높이고 싶습니다. 내 스크립트가 KeePass URL 필드에서 직접 실행되기 때문에 일반 텍스트 비밀번호에 대해 걱정할 필요가 없습니다(doubleclick은 스크립트를 실행하고 스크립트 뒤의 agrument/KeePass {Placeholder}를 통해 올바른 비밀번호로 채웁니다). 어떤 명령도 실행하지 않고 우분투 시스템으로 다시 "연결을 끊는" 원격 루트 셸을 제외하고는 이 모든 작업을 수행할 수 있었습니다. 그래서 제가 원격으로 실행하려고 하는 명령은 4-5초 동안 실행되지 않고 갑자기 우분투 시스템에서 무슨 일이 일어났는지 알려주지 않고 실행됩니다.

원격 쉘이 완전히 작동하려면 어떻게 해야 합니까? SSH 키와 직접 루트 로그인은 나에게 솔루션이 아닙니다. Sophos UTM이 너무 많기 때문입니다.

일어나는 일을 설명했습니다.

sshtool.sh:
#!/usr/bin/expect -f
spawn sshpass -pPASSWORD ssh -t [email protected] "sudo su -"
expect -- "oot's password:"
send "PASSWORD\r"
expect -- "/root #"
expect eof



What happens in the terminal:
vct@vct-virtual-machine:~$ ./sshtool.sh
spawn sshpass -pPASSWORD ssh -t [email protected] sudo su -
root's password:
utm:/root # whoami
# *enter*
# not reacting for 4-5 seconds
vct@vct-virtual-machine:~$ whoami
vct
vct@vct-virtual-machine:~$

이와 같이 스크립트를 변경하면 연결 끊김 문제에 도움이 되지 않습니다.

sshtool.sh:
#!/usr/bin/expect -f
spawn ssh [email protected]
expect -- "password:"
send "PASSWORD\r"
expect -- "/home/login > "
send -- "sudo su -\r"
expect -- "oot's password:"
send "PASSWORD\r"
expect -- "/root #"
send -- "whoami\r"
expect eof


vct@vct-virtual-machine:~$ ./sshtool.sh
spawn ssh [email protected]
[email protected]'s password:
Last login: Mon Apr 18 09:14:41 2016 from 192.168.1.44


Sophos UTM
(C) Copyright 2000-2015 Sophos Limited and others. All rights reserved.
Sophos is a registered trademark of Sophos Limited and Sophos Group.
All other product and company names mentioned are trademarks or registered
trademarks of their respective owners.

For more copyright information look at /doc/astaro-license.txt
or http://www.astaro.com/doc/astaro-license.txt

NOTE: If not explicitly approved by Sophos support, any modifications
      done by root will void your support.

<M> loginuser@utm:/home/login > sudo su -
root's password:
# Following "whoami" directly executed by the script itself works fine
<M> utm:/root # whoami
root
# After 4-5 seconds, it's dropping the connection again
<M> utm:/root # vct@vct-virtual-machine:~$

미리 감사드립니다!

답변1

이와 비슷한 문제가있었습니다. 문제는 내 원격 .bashrc 파일에 대화형으로 실행되지 않는 경우 아무 작업도 수행하지 않는 일부 줄이 있다는 것입니다.

관련 정보