I am running a php script and trying to connect via SFTP and transfer files or connect even, what can I do, what libraries would you need and or patches?

Make SSH connections with PHP

Hope this can help.

Thank you very much, it was helpful.

I recently tried to get SFTP on PHP working and found that phpseclib was a lot easier to use:

PHP Secure Communications Library

If you have the luxury of not being on a shared host and can install whatever extensions you want to maybe the PECL extension would be better but not all of us are so lucky.