如何以编程方式在 iPhone 上设置 ssh 隧道来访问远程服务?
我正在开发一个 iPhone 应用程序,它通过 tcp 套接字连接与远程服务进行通信(该服务实际上侦听 telnet 并也接受 telnet 命令)。连接当然是不安全的,所有请求(带有大量敏感数据,例如密码)和响应都以纯文本形式传输。我的第一反应是考虑使用 ssl 的 Web 服务,但从头开始开发 Web 服务似乎太漫长了。
因此,我一直在考虑使用 ssh 隧道来保护流量。是否可以在 iPhone 应用程序中设置 ssh 隧道(例如使用 libssh2),然后使用该隧道安全地连接到远程服务?如果是这样,我应该如何设置隧道,最重要的是,我应该如何连接到远程服务并发出命令/接收响应?最后,关于隧道我应该注意什么?
编辑:我忘了提及运行该服务的服务器正在使用 Windows。 SSH是通过Cygwin实现的。
如果这个问题太基础了,我很抱歉,但这确实是我第一次真正接触 ssh。
I am developing an iPhone application which is communicating with a remote service over a tcp socket connection (the service actually listens on telnet and takes telnet commands too). The connection is of course insecure and all requests (with quite a bit of sensitive data, such as passwords) and responses are transmitted as plain text. My first reaction was to consider a web service with ssl, but developing a web service from scratch seems too lengthy.
Because of that I have been thinking of using an ssh tunnel in order to secure the traffic. Is it possible to set up an ssh tunnel in an iPhone application (with libssh2 for example) and then use that tunnel to securely connect to the remote service? If so, how should I set up the tunnel and most importantly, how should I connect to the remote service and give commands/receive responses? Lastly, what should I keep in mind regarding the tunnel?
EDIT: I forgot to mention that the server running the service is using Windows. SSH is achieved via Cygwin.
I am sorry if the question is too basic but this is really my first real brush with ssh.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为使用 ssh 隧道可能会遇到更多安全问题,因为没有一种安全的方法来绑定应用程序中的身份验证信息,而且,如果有人可以获得该登录信息,他们可以连接到您的 ssh 会话并开始试图发出任意命令。当然,有很多方法可以锁定 ssh 会话,但我仍然对此非常警惕。至少对于 Web 服务,它充当 iPhone 应用程序和 Telnet 会话之间的“经纪人”,因此您可以添加额外的保护层。
I think you may have more security issues by using an ssh tunnel because there isn't a secure way to tie down the authentication information in the app and well, if someone can get that login information they could conceivably connect to your ssh session and start trying to issue arbitrary commands. Of course there are ways to lock down an ssh session, but still, I'd be very wary of that. At least with a web service, it acts as a "broker" between the iPhone app and the telnet session so you can add an extra layer of protection.