The Web server, and thus your PHP code, runs as a different UID than your own UID. The UID of the web server requires a password to login, if it's UID allows logins at all. Perhaps specify the username for whom you want the directory listing to be done.
Code:
ssh joeBloggs@127.0.0.1 ls /
--- rod.