擅长:python、mysql、java
<p>因为您是在ssh上运行命令,所以没有运行登录shell,因此<code>.bashrc</code>不是源代码。在</p>
<p>请看这里的答案:<a href="https://superuser.com/questions/306530/run-remote-ssh-command-with-full-login-shell">https://superuser.com/questions/306530/run-remote-ssh-command-with-full-login-shell</a></p>
<p>编辑:</p>
<p>调用<a href="http://docs.paramiko.org/en/1.15/api/client.html#paramiko.client.SSHClient.exec_command" rel="nofollow noreferrer">exec_command</a>时尝试设置<code>get_pty=True</code></p>
<p>否则,请尝试强制登录shell</p>
<pre><code>exec_command('bash -l -c "sanity;"')
</code></pre>