I'm working with phpseclib (https://github.com/phpseclib/phpseclib) and I come across a problem that I don't know how to solve.
So basically I would like to use PHP to connect to the same server that the script is running on via SSH to perform some SFTP transaction.
I tried ssh localhost
on command line and it logs me in using my SSH key-pair.
I implemented phpseclib to download/upload files from/to a remote server. Now I am writing unit tests for the code I've written. However, I cannot mock SFTP class since the object needs to be initiated for every connection, is there a way to test the function that I've written, basically just a file download and process data function.
My guess: your
~/.ssh/id_rsa
file is the private key corresponding to the public key in~/.ssh/authorized_keys
. So when you try to login withssh localhost
it isn't actually logging you without authentication - it's logging you in with a public key but you just don't realize it.A few other less likely possibilities:
Doing
ssh -v localhost
and then posting what it says might be helpful.