2012-08-28 36 views
1

我是Windows XP的計算機上連接,安裝WAMP。目前,我正在使用putty連接我的遠程Linux機器。如何遠程Linux機器通過PHP在Windows環境

我想執行的Linux通過PHP命令了shell_exec()方法(CP,LS,...)。

是否有人知道如何先連接我的Linux系統中,然後運行這些命令在Windows環境中?

任何建議的將高度讚賞...

+0

所以你想從Linux的盒子連接到你的Windows wamp? – nooitaf

回答

1

Windows您不能運行Linux命令。 您可以使用putty通過SSH運行它們。看來你有這種跑步。

您可以轉發通過ssh連接。看膩子屏幕,去Connection > SSH > Tunnels

然後添加一個地道:

source port: 1234 
destination port: localhost:80 
type is Local 

所以你打開Internet Explorer,鍵入ADDRES條:http://localhost:1234端口1234隨後被轉發到端口80上的遠程Linux的PC。

您還可以通過設置

destination port: *ip of the wamp server*:80 

然後你就可以從網絡存取權限之外的Windows PC,只要putty運行它轉發到WAMP。

0

這聽起來像你想要Windows上的PHP腳本在遠程Linux服務器上運行SSH命令。爲此,請參閱the PHP SSH2 extension

綁定到libssh2庫,提供一種使用安全的加密傳輸遠程機器上 訪問資源 (殼,遠程執行,隧道,文件傳輸)。

這將允許您通過SSH連接到Linux服務器和執行命令刪除服務器(cpls等)上。下面是一些示例代碼:

$connection = ssh2_connect('shell.example.com', 22); 
ssh2_auth_password($connection, 'username', 'password'); 
$stream = ssh2_exec($connection, 'hostname'); 
echo "Output: " . stream_get_contents($stream); 

這是值得注意的是,這可能不是去這任務最安全或最可靠的方法。

0

我不認爲你可以在Windows機器上執行Linux命令。

您可能要考慮使用OpenSSH for Windows 並跳過php。

但你會得到你一個Windows外殼。 C:\\>並且沒有lscp,但是否則完全控制。

你也可以試驗並運行一個虛擬機與Linux和共享你的Windows驅動器。

remote server linux - - 噓 - - >local virtual linux - - - 共享文件夾 - - >windows

相關問題