Managing SFTP Connections Efficiently in a Layer

How would I go about handling an SFTP connection in a layer? I don't think I would want to open the connection upon creating the layer since I don't want it to be forever running if I am not using it. But I also don't want to open and close one for each action.

Im thinking maybe open upon first action, and then close when the connection has not been used for a set period of time. How would I best go about this?
Was this page helpful?