Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once '../lib/phpSec/bootstrap.php';
- require_once 'SplClassLoader.php';
- $classLoader = new SplClassLoader('phpSec', '../Generic/lib');
- $classLoader->register();
- $server = "123.456.789.012";
- $port = "22";
- $username = "xxx";
- $password = "xxx";
- set_include_path(get_include_path() . PATH_SEPARATOR . 'c:Apachehtdocsphpseclib');
- define('NET_SSH2_LOGGING', 2);
- include 'phpseclib/Net/SFTP.php';
- define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);
- $sftp = new Net_SFTP($server);
- // Check SFTP Connection
- if (!$sftp->login($username, $password))
- {
- echo 'Login Failed.';
- print "</br>";
- $ERR1 = $sftp->getSFTPErrors();
- print_r($ERR1);
- print "</br>";
- $ERR2 = $sftp->getErrors();
- print_r($ERR2);
- }
- else
- {
- echo 'Connected to SFTP.';
- echo $sftp->pwd();
- }
- ?>
- try{
- $sftp->login($username, $password);
- }
- catch(Exception $e){
- echo $e->getMessage();
- }
- <?php
- $connection = ssh2_connect('shell.example.com', 22);
- ssh2_auth_password($connection, 'username', 'password');
- $sftp = ssh2_sftp($connection);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement