2014-03-19 2 views
2

ssh 명령을 실행하려고합니다.강제 명령이 켜져있을 때 paramiko가 작동하지 않습니다.

ssh 서버에 강제 명령 옵션이 있으면 스크립트가 중지되고 시간 초과가 만료되는 동안 아무 작업도 수행하지 않습니다. 디버그 로그가 있습니다. "Force command"줄을 확인할 수 있습니다.

DEBUG:paramiko.transport:starting thread (client mode): 0xb6d1bb4cL 
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_6.0p1) 
DEBUG:paramiko.transport:kex algos:[u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group-exchange-sha1', u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa', u'ssh-dss', u'ecdsa-sha2-nistp256'] client encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'[email protected]'] server encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'[email protected]'] client mac:[u'hmac-md5', u'hmac-sha1', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-256-96', u'hmac-sha2-512', u'hmac-sha2-512-96', u'hmac-ripemd160', u'[email protected]', u'hmac-sha1-96', u'hmac-md5-96'] server mac:[u'hmac-md5', u'hmac-sha1', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-256-96', u'hmac-sha2-512', u'hmac-sha2-512-96', u'hmac-ripemd160', u'[email protected]', u'hmac-sha1-96', u'hmac-md5-96'] client compress:[u'none', u'[email protected]'] server compress:[u'none', u'[email protected]'] client lang:[u''] server lang:[u''] kex follows?False 
DEBUG:paramiko.transport:Ciphers agreed: local=aes128-ctr, remote=aes128-ctr 
DEBUG:paramiko.transport:using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none 
DEBUG:paramiko.transport:Switch to new keys ... 
DEBUG:paramiko.transport:Adding ssh-rsa host key for 8.8.8.8: 54c2349797979732dda94989530c1f4 
DEBUG:paramiko.transport:Trying SSH key 7d834324323429b09824eb 
DEBUG:paramiko.transport:userauth is OK 
INFO:paramiko.transport:Authentication (publickey) successful! 
DEBUG:paramiko.transport:Debug msg: Forced command. 
DEBUG:paramiko.transport:Debug msg: Port forwarding disabled. 
DEBUG:paramiko.transport:Debug msg: X11 forwarding disabled. 
DEBUG:paramiko.transport:Debug msg: Agent forwarding disabled. 
DEBUG:paramiko.transport:Debug msg: Pty allocation disabled. 
DEBUG:paramiko.transport:[chan 1] Max packet in: 34816 bytes 
DEBUG:paramiko.transport:[chan 1] Max packet out: 32768 bytes 
INFO:paramiko.transport:Secsh channel 1 opened. 
DEBUG:paramiko.transport:[chan 1] Sesch channel 1 request ok 

이 옵션을 사용하지 않으면 모든 것이 정상적으로 작동합니다. 왜 그렇게됩니까? 어떻게 고칠 수 있니?

+0

pwd 대신 실행되는 명령은 무엇입니까? 아마도 실행하는 데 너무 오래 걸리는 것 같습니다. – ScoPi

답변

0
DEBUG:paramiko.transport:Debug msg: Forced command. 

해결 방법이 없습니다. 서버가 키에 대한 강제 명령으로 구성된 경우, 해당 키를 사용하여 여는 모든 세션은 서버가 사용자가 요청한 명령을 무시하고 대신 강제 명령을 호출하게합니다.

서버가 어떤 명령을 실행하는지 알지 못하는 이유는 무엇인지 파악할 방법이 없습니다. 강제 명령은 원격 ssh 클라이언트로부터의 입력을 기다리고있을 수 있으며,이 경우 무한정 대기합니다.

forced 명령은 "SSH_ORIGINAL_COMMAND"환경 변수를 통해 클라이언트가 요청한 원래 명령에 액세스 할 수 있습니다. forced 명령은이 변수를 검사하고 클라이언트가 요청한 명령을 호출 할 수 있지만 강제 명령은이 기능을 염두에두고 작성해야합니다.

관련 문제