使用批处理文件连接到 Linux 服务器时出错。能够与 Filezilla 连接

发布于 2024-09-25 09:23:39 字数 557 浏览 6 评论 0原文

我正在尝试在 VB 6.0 应用程序中通过 FTP 连接到远程服务器。

我尝试使用 Inet 连接到远程服务器,但出现状态未知错误(代码:120089)。所以我试图通过批处理文件来做到这一点。我创建了一个批处理文件,如下所示:-(

open 192.168.1.3 22  
root  
!@#%RedHat%)(*  
cd "/opt/test"  
put "C:\envars.exe" "envars.exe"  
bye  

用户名是“root”&
密码是!@#%RedHat%)(*

我尝试从命令提示符运行批处理文件,如下所示:- C:>ftp -s:F:\testScript.txt

现在我收到以下错误:- “ftp:连接:未知错误号”

以前我收到消息, “已连接” 其次是, “连接被远程主机关闭。”

但是,我可以使用 Filezilla 连接到此服务器。

如果您能够找出问题所在,请告诉我。

提前致谢
苏吉特

I am trying to connect to a remote servre via FTP in my VB 6.0 application.

I tried connecting to remote server using Inet but it gave status unknown error (code:120089). So I am trying to do this by batch file. I created a batch file as below:-

open 192.168.1.3 22  
root  
!@#%RedHat%)(*  
cd "/opt/test"  
put "C:\envars.exe" "envars.exe"  
bye  

( username is 'root' &
password is !@#%RedHat%)(*
)

I tried running the batch file from the command prompt as follows:-
C:>ftp -s:F:\testScript.txt

Now I am getting the following error:-
"ftp: connect : unknown error number"

Previously I was getting message,
"connected"
followed by,
" connection closed by remote host."

However, I am able to connect to this server using Filezilla.

Please let me know if you are able to figure out what is the issue.

Thanks in advance
Sujit

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吾性傲以野 2024-10-02 09:23:39

确定想要连接到端口 22 吗? 21 是常用的 FTP 端口。

此外,您应该尝试手动执行该脚本(运行ftp并自己输入它们)以查看错误发生的位置。您的防火墙可能会阻止主动模式下的返回流量(查看 Filezilla 是否在被动模式下运行)。


根据您的评论,您肯定正在连接到安全的 FTP 服务器。 Windows 附带的ftp.exe 程序仅执行标准FTP。

快速谷歌一下“Windows ftps 客户端”,发现了许多可能性,其中之一是 Putty 中的安全 FTP 客户端,这是我们在工作中使用(并强烈推荐)的工具。另一个是 CygWin 附带的 sftp。

我不认为这两个方法都允许您以交互方式指定密码。他们正确地假设您将它们用于安全目的,并且在脚本中使用明文密码将使安全性变得毫无意义。

您最好的选择是按照 SSH 希望的方式设置共享密钥。这是最安全的方法。

但是,如果您对设置的简便性而不是安全性更感兴趣,则可以仅使用 expect 等待密码提示,然后将密码提供给 SFTP 程序。 CygWin 还附带了 expect (Putty 没有),所以我建议使用那。

Are you sure you want to be connecting to port 22? 21 is the usual FTP port.

Additionally, you should try to execute that script manually (run ftp and type them in yourself) to see where the error occurs. It may be that your firewall is blocking return traffic in active mode (see if Filezilla is running in passive mode).


Based on your comment, you're definitely connecting to a secure FTP server. The ftp.exe program that comes with Windows only does standard FTP.

A quick Google of "ftps client for windows" turns up many possibilities, one of which is a secure FTP client in Putty, a tool we use (and highly recommend) at work. Another is sftp that comes with CygWin.

I don't believe either of these allow you to specify a password other than interactively. They rightly assume that you're using them for security purposes and having a password in plaintext in a script would render the security moot.

Your best option is to set up shared keys the way SSH wants you to. That is the most secure way.

However, if you're more interested in ease of setup rather than security, you can just use expect to await the password prompt and then give your password to the SFTP program. CygWin also comes with expect (Putty doesn't) so I'd suggest using that.

苦笑流年记忆 2024-10-02 09:23:39

您应该在端口 21 上进行连接。端口 22 用于 SSH 连接,这解释了为什么 Filezilla 可以连接,因为它支持 FTPS(FTP over SSH)。

You should connect on port 21. Port 22 is for SSH connections, which explains why Filezilla can connect as it supports FTPS (FTP over SSH).

清旖 2024-10-02 09:23:39

如果不评论密码的适当性(或其他),您使用的几个字符可能会被批处理文件解释为特殊字符。检查(可能通过 ECHO 语句)并确保该特定字符串按原样传递。

Without commenting on the appropriatness (or otherwise) of your password, several of the characters you used may be interpreted as special characters by batch files. Check (perhaps via ECHO statement) and make sure that that particular string is being passed through as-is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文