ronf / asyncssh

AsyncSSH is a Python package which provides an asynchronous client and server implementation of the SSHv2 protocol on top of the Python asyncio framework.
Eclipse Public License 2.0
1.49k stars 143 forks source link

connect not running ~/.bash_profile #649

Open krankydonkey opened 1 month ago

krankydonkey commented 1 month ago

Running async with asyncssh.connect(ip, username=uname, password=passwd, known_hosts=None) as conn Within a podman container will log in as the given user, but does not run the ~/.bash_profile file.

Running ssh uname@ip and giving the password at the prompt works as expected.

Any ideas why this would be the case?

ronf commented 1 month ago

Did you actually open a session after opening the connection? You need to call something like conn.run() after opening a connection to actually run a command (or a shell), and only then will the remote system run something like ~/.bash_profile. See the example at https://asyncssh.readthedocs.io/en/latest/#simple-client.

krankydonkey commented 1 month ago

Yes, I ran conn.run(command, check=False) and it ran without the bash_profile loaded

On Wed, 10 Apr 2024, 2:49 pm Ron Frederick, @.***> wrote:

Did you actually open a session after opening the connection? You need to call something like conn.run() after opening a connection to actually run a command (or a shell), and only then will the remote system run something like ~/.bash_profile. See the example at https://asyncssh.readthedocs.io/en/latest/#simple-client.

— Reply to this email directly, view it on GitHub https://github.com/ronf/asyncssh/issues/649#issuecomment-2046533435, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHKJXKC2FFOA2DVYAWJDUMTY4TAEDAVCNFSM6AAAAABF7R7AAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBWGUZTGNBTGU . You are receiving this because you authored the thread.Message ID: @.***>

ronf commented 1 month ago

Actually, if you are trying to run a command, I'm not sure that I'd expect .bash_profile to run. Doesn't that run only on login shells?

ronf commented 1 month ago

I've confirmed that running 'ssh' with a command to execute will not run what's in .bash_profile. However, running 'ssh' and requesting an interactive shell WILL run .bash_profile. This is standard bash behavior, and has nothing to do with AsyncSSH.