Python Paramiko get_transport() and open_session() functions explanation

Viewed 226

Thank you for reading this.

It's a short question but I don't quite get the idea of the functions and I have not seen any other posts on stackoverflow about this.

If I use this code (of course after connecting to the ssh server):

client = client.get_transport().open_session()

I literally can't find proper information on get_transport() (not even in de documentation), but I expect it to return a socket (tcp) object, if that's true, what does open_session() do? The documentation says the following:

Request a new channel to the server, of type "session". This is just an alias for calling open_channel with an argument of "session".

This is not quite clear to me, what is meant with "a new channel to the server of type session" and can someone explain to me what both functions actually do?

I really appreciate any answer! Have an amazing day :)!

1 Answers

SSH protocol has multiple layers.
See https://en.wikipedia.org/wiki/Secure_Shell#Architecture

The "transport" layer the lowest layer. But it's still above TCP, so above Python Socket. And I believe that in Paramiko, the Transport class actually implements both the "transport" layer and the "user authentication" layer. As such, it is responsible for creating the "connection" layer, aka the sessions and channels.

Related