【难题】delphi能开发出SSH功能的客户端软件吗?

NetG 2009-07-09 02:55:45
类似:SSH Secure Shell for Workstations replaces other, insecure terminal applications, such as Telnet and FTP. It allows you to securely login to remote host computers, to execute commands safely on a remote computer, and to provide secure encrypted and authenticated communications between two hosts in an untrusted network. X11 connections and arbitrary TCP/IP ports can also be forwarded over the secure channel, expanding SSH Secure Shell for Workstations's usability even further.

The SSH2 protocol contains the following features:


Secure terminal sessions utilizing secure encryption.
Full, secure replacement for FTP and Telnet, as well as the UNIX r-series of commands: rlogin, rsh, rcp, rexec.
Multiple high security algorithms and strong authentication methods that prevent such security threats as identity spoofing and man-in-the-middle attacks.
Multiple ciphers for encryption, including e.g. 3DES, Blowfish and AES.
Password, public key, certificate, smart card, PAM and SecurID authentication methods.
Transparent and automatic tunneling of X11 connections and arbitrary TCP/IP-based applications, such as e-mail.
Automatic and secure authentication of both ends of connection. Both the server and the client are authenticated to prevent identity spoofing, Trojan horses, etc.
Unique secure file transfer interface (SFTP) fully integrated in the client software.
Multiple channels that allow you to have multiple terminal windows and file transfers going through one secure and authenticated connection.



应该可以开发出Telnet的,SSH的很难吗?
先咨询,如可行再散分,呵呵。
...全文
631 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenxing123 2010-01-28
  • 打赏
  • 举报
回复
我用delphi封装了SSH的DLL,开发了一个客户端
NetG 2009-07-09
  • 打赏
  • 举报
回复
请回复http://topic.csdn.net/u/20090709/22/f0ff8636-3d6e-483c-9d3b-329ee7f5b769.html?97852
要结贴了,呵呵。
感谢的话就不多说了,握手。
haitao 2009-07-09
  • 打赏
  • 举报
回复
具体忘了,最不济,自己在OnNewLine里累加。。。。。。。
发命令,就直接用 DosCommand1.SendLine(Edit2.Text,true)——对
NetG 2009-07-09
  • 打赏
  • 举报
回复
哦,明白了

1.多行判断:是DosCommand1.Lines这个属性吗?还是DosCommand1.OutputLines属性?
估计实际需要判断输出的倒数1至3行吧,
2.然后再发命令,这时候发命令,就直接用 DosCommand1.SendLine(Edit2.Text,true)就行吧?

haitao 2009-07-09
  • 打赏
  • 举报
回复
无须timer,直接在OnNewLine里加监控条件:
遇到什么信息,该发什么命令
当然,要注意状态切换,另外,有些条件也许需要多行连起来判断的

onNewline是事件,会自动触发的
NetG 2009-07-09
  • 打赏
  • 举报
回复
明白些了。
但没思路,
实现目标是:

ssh到服务器后执行以下序列命令:(例如)
telnet ip
等待出现 user:出现后输入用户名
等待出现 password:出现后输入密码
等待出现 #符号:出现后开始输入命令 ftp ip
等待出现 user:出现后输入密码
......
类似这样的。


在 DosCommand1NewLine 里,NewLine应该是输出的信息,对它进行判断吧
判断我初步想用time控件,去查看newline的值,如果符合条件,就输入下一条字符,
这里用DosCommand1.SendLine输入下一条字符吗?

方案可行否?


这是关键,呵呵。
haitao 2009-07-09
  • 打赏
  • 举报
回复
onNewline是事件,会自动触发的
好像也有同步的模式,具体忘了

[00;34m.kde[00m 应该是输出文本附加的颜色设置
NetG 2009-07-09
  • 打赏
  • 举报
回复
执行ls -la显示得怎么很乱呢?

21:25:30.921 @>drwxr-xr-x 3 web web 4096 Mar 7 2006 [00;34m.kde[00m
21:25:30.937 @>drwx------ 3 web web 4096 Apr 22 2007 [00;34m.metacity[00m
21:25:30.937 @>drwxr-xr-x 3 web web 4096 Apr 22 2007 [00;34m.nautilus[00m
21:25:30.953 @>-rw-r--r-- 1 web web 458 Mar 25 2006 [00m.profile[00m
21:25:30.953 @>-rw-r--r-- 1 web web 12288 Mar 23 2006 [00m.profile.swp[00m
21:25:30.953 @>-rw------- 1 web web 0 Apr 22 2007 [00m.recently-used[00m
21:25:30.968 @>-rw------- 1 web web 497 Apr 22 2007 [00m.rhn-applet.conf[00m

多了那么多乱七八糟的东西。
NetG 2009-07-09
  • 打赏
  • 举报
回复
明白些了。
但没思路,
实现目标是:

ssh到服务器后执行以下序列命令:(例如)
telnet ip
等待出现 user:出现后输入用户名
等待出现 password:出现后输入密码
等待出现 #符号:出现后开始输入命令 ftp ip
等待出现 user:出现后输入密码
......
类似这样的。


在 DosCommand1NewLine 里,NewLine应该是输出的信息,对它进行判断吧
判断我初步想用time控件,去查看newline的值,如果符合条件,就输入下一条字符,
这里用DosCommand1.SendLine输入下一条字符吗?

方案可行否?
haitao 2009-07-09
  • 打赏
  • 举报
回复
在这个事件里截取程序的输出:
procedure TForm1.DosCommand1NewLine(Sender: TObject; NewLine: String;
OutputType: TOutputType);
begin
if OutputType=otEntireLine then
log( '>'+ NewLine)
else
log( '<'+ NewLine);
end;
NetG 2009-07-09
  • 打赏
  • 举报
回复
想写程序实现:
在pink下输入命令,如:ls -la,等到这个ls命令执行完毕后(此处如何检测呢?)
可能再接着输入下一条命令,等待执行完毕后,再决定下一步的操作。
现在不知道如果检测输出结果。
里面提供的帮助如下:
How to use it :
---------------
- just put the line of command in the property 'CommandLine'
- execute the process with the method 'Execute'
- if you want to stop the process before it has ended, use the method 'Stop'
- if you want the process to stop by itself after XXX sec of activity,
use the property 'MaxTimeAfterBeginning'
- if you want the process to stop after XXX sec without an output,
use the property 'MaxTimeAfterLastOutput'
- to directly redirect outputs to a memo or a richedit, ...
use the property 'OutputLines'
(DosCommand1.OutputLnes := Memo1.Lines;)
- you can access all the outputs of the last command with the property 'Lines'
- you can change the priority of the process with the property 'Priority'
value of Priority must be in [HIGH_PRIORITY_CLASS, IDLE_PRIORITY_CLASS,
NORMAL_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS]
- you can have an event for each new line and for the end of the process
with the events 'procedure OnNewLine(Sender: TObject; NewLine: string;
OutputType: TOutputType);' and 'procedure OnTerminated(Sender: TObject);'
- you can send inputs to the dos process with 'SendLine(Value: string;
Eol: Boolean);'. Eol is here to determine if the program have to add a
CR/LF at the end of the string.
*******************************************************************
How to call a dos function (win 9x/Me) :
----------------------------------------

Example : Make a dir :
----------------------
- if you want to get the result of a 'c:\dir /o:gen /l c:\windows\*.txt'
for example, you need to make a batch file
--the batch file : c:\mydir.bat
@echo off
dir /o:gen /l %1
rem eof
--in your code
DosCommand.CommandLine := 'c:\mydir.bat c:\windows\*.txt';
DosCommand.Execute;

Example : Format a disk (win 9x/Me) :
-------------------------
--a batch file : c:\myformat.bat
@echo off
format %1
rem eof
--in your code
var diskname: string;
--
DosCommand1.CommandLine := 'c:\myformat.bat a:';
DosCommand1.Execute; //launch format process
DosCommand1.SendLine('', True); //equivalent to press enter key
DiskName := 'test';
DosCommand1.SendLine(DiskName, True); //enter the name of the volume
*******************************************************************}


您提供的代码,好像没有判断输出结果的地方。关键就想知道如果判断输出结果,然后才决定下一步该执行哪条命令。
haitao 2009-07-09
  • 打赏
  • 举报
回复
procedure TForm1.DosCommand1NewLine(Sender: TObject; NewLine: String;
OutputType: TOutputType);
begin
if OutputType=otEntireLine then
log( '>'+ NewLine)
else
log( '<'+ NewLine);
end;

procedure TForm1.BtnRunCmdClick(Sender: TObject);
begin
BtnRunCmd.Enabled:=false;
CBlockout.Enabled:=false;
DosCommand1.CommandLine:=Edit1.Text;
log('[Begin:'+Edit1.Text);

//Memo1.Visible:=false;
if self.CBlockout.Checked then
Memo1.Lines.BeginUpdate;
application.ProcessMessages;

DosCommand1.Execute;

end;

procedure TForm1.DosCommand1Terminated(Sender: TObject);
begin
if self.CBlockout.Checked then
Memo1.Lines.EndUpdate;
//Memo1.Visible:=true;

log('End]');

BtnRunCmd.Enabled:=true;
CBlockout.Enabled:=true;
end;

procedure TForm1.log(const s: String);
begin
Memo1.Lines.Add(formatdatetime('hh:nn:ss.zzz|',now)+s);
end;

procedure TForm1.BtnInputClick(Sender: TObject);
begin
DosCommand1.SendLine(Einput.Text,CBreturn.Checked);
end;
NetG 2009-07-09
  • 打赏
  • 举报
回复
DosCommand.pas
此控件不知道怎么用的,有例子吗?
不好意思,再次麻烦了。
NetG 2009-07-09
  • 打赏
  • 举报
回复
好的,晚上,回家试试,非常感谢,如解决,开贴致谢。。。。。。
haitao 2009-07-09
  • 打赏
  • 举报
回复
http://maxxdelphisite.free.fr/doscmd.htm
NetG 2009-07-09
  • 打赏
  • 举报
回复
doscmd控件 是delphi的控件吗???能提供吗
plink.exe我已经找到了,是dos的命令程序。
NetG 2009-07-09
  • 打赏
  • 举报
回复
doscmd控件 是delphi的控件吗???能提供吗
plink.exe 是啥?哪有?
解决后再送你50分表示心情(分也不多,怕以后没咧)
haitao 2009-07-09
  • 打赏
  • 举报
回复
哦,需求是这样啊。

最好是用doscmd控件来操作plink.exe,非常方便
NetG 2009-07-09
  • 打赏
  • 举报
回复
我负责多台服务器,大约60台左右,都是用ssh登陆管理的,有些日常工作很繁琐的。
想做个程序,但不知道如何用delphi编写程序访问。
现在都是用 SSH Secure Shell 3.2.9 (Build 283)客户端软件。
之前用autoit写了点模拟键盘操作的程序,但无法检测执行命令后的结果,有点傻。
请问思路是啥?有demo吗?
haitao 2009-07-09
  • 打赏
  • 举报
回复
应该没问题

比较麻烦的地方是ssl的实现比较复杂,一般都是借助于通用的dll

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧