0

I'm trying to connect to a SFTP server using phpseclib, only it doesn't work and I can't seem to figure out why.

I have the following:

$ssh = new SSH2('some.server.tld');
if (!$ssh->login('username')) {
    throw new LocalizedException(__('cannot login'));
}

some.server.tld has my public key and I am able to connect using a default ssh-command in my terminal using the same credentials, but for some reason phpseclib doesn't work.

I tried getting errors from phpseclib, but nothing is thrown. Not even when I enable the error logging. Zero: no errors.

Anyone knows what might be going wrong here?

Giel Berkers
  • 2,852
  • 3
  • 39
  • 58
  • 1
    Have you provided your keyfile (not visible from the code)? See answer 1 in this thread: https://stackoverflow.com/questions/41584098/phpseclib-connect-to-localhost-using-sftp-ssh – Honk der Hase Mar 21 '18 at 16:10
  • When you do the SSH on the command line you are sure it's not the terminal that is prompting for the credentials? [No Auth example](http://phpseclib.sourceforge.net/ssh/2.0/auth.html#noauth) – ficuscr Mar 21 '18 at 16:21
  • 1
    *"using the same credentials"* - What credentials? There's only username in your code. + Show us `ssh -vv` output, so that we can see what authentication method you are actually using. – Martin Prikryl Mar 21 '18 at 18:08
  • @MartinPrikryl: when I `ssh` using my terminal, the authentication is done by my public key being known by the remote host, but if I understand correctly, I have to explicit set my private key in my PHP code because it does not automatically know about my private key, which makes sense of course – Giel Berkers Mar 22 '18 at 07:37

0 Answers0