您的位置:首页 >> Web开发 >> PHP技术 >> PHP教程 >> 正文
PHP教程 RSS
 

将SSH与PHP相连接确保传输数据的安全

http://www.rdxx.com 08年05月13日 01:47 我要投稿

关键词: 传输 , PHP , SSH , 连接 , 安全 , 数据 , HP

  // try to authenticate with username root, password secretpassword

  if(!ssh2_auth_password($con, "root", "secretpassword")) {

  echo "fail: unable to authenticate\n";

  } else {

  // allright, we're in!

  echo "okay: logged in...\n";

  // execute a command

  if(!($stream = ssh2_exec($con, "ls -al" )) ){

  echo "fail: unable to execute command\n";

  } else{

  // collect returning data from command

  stream_set_blocking( $stream, true );

  $data = "";

  while( $buf = fread($stream,4096) ){

  $data .= $buf;

  }

  fclose($stream);

  }

  }

共2页  1 2


 
 
标签: 传输 , PHP , SSH , 连接 , 安全 , 数据 , HP 打印本文
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站