How to set port forwarding from SSH Server to Web Server?

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
apple12
Posts: 6
Joined: Tue 06 Nov 2007 02:14

How to set port forwarding from SSH Server to Web Server?

Post by apple12 » Tue 06 Nov 2007 02:23

How to set port forwarding from SSH Server to Web Server?
I have a web server to accept some html file and I need to add SSH server for security channel.
I have checked the sample, there only has SSH Client sample to show the port forwarding.
How to make SSH Server(22) port forward to Web Server(80)?

Thanks!

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 06 Nov 2007 15:04

The SSH operation principle is the next: data from SSH client is transmitted to SSH server in secure form. SSH server decodes the data and transmits it in plain form to the specified host and port, to which point TScSSHChannel.DestHost and TScSSHChannel.DestPort correspondingly.
When local port forwarding, TScSSHChannel listens to the port specified in TScSSHChannel.SourcePort, receives data, encodes and transmits it to the server. Server decodes data and transmits it further.
You can find more detailed information about it in the SecureBridge help.

Seemingly, you should setup the client in the following way:
ScSSHCient.HostName := SSHServerHost;
ScSSHCient.Port := 22;
ScSSHChannel.DestHost := WebServer;
ScSSHChannel.DestPort := 80.
If WebServer and SSH server are located on the same computer, you can specify 'localhost' in ScSSHChannel.DestHost.

apple12
Posts: 6
Joined: Tue 06 Nov 2007 02:14

Post by apple12 » Wed 07 Nov 2007 01:43

I am using ScSSHServer for SSH Server.
After receive data from SSH Server, I have to redirect the data into Web Server.
I have checked the sample program for ScSSHClient for port forwarding.
However, how to make SSH Server (ScSSHServer) to do port forwarding?
I cannot find ScSSHServer can call ScSSHChannel.

apple12
Posts: 6
Joined: Tue 06 Nov 2007 02:14

Post by apple12 » Wed 07 Nov 2007 03:20

One more question:
How to send data from Web Server to SSH Server?
I use IdHTTPServer (Indy) to make the Web Server.
Normally, if no SSH Server, the following can sent message to client:
AResponseInfo.ContentText := '200 OK';

If there has a SSH Server, what should I do ?

Thanks!

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 07 Nov 2007 08:07

Please specify, what Web client and what SSH client do you use.

apple12
Posts: 6
Joined: Tue 06 Nov 2007 02:14

Post by apple12 » Wed 07 Nov 2007 08:45

Web client is a machine which will generate html file periodically.
SSH Client is Open SSH run under Linex.

Web Client SSH Client SSH Server Web Server

Web Client will iniate to transfer to data file to Web Server through SSH.
When Web Server process the data file, it will send a message 'OK' back to Client through SSH.

Now, when Client try to connect, it show
'Format of Server Version is invalid' and the connection is hang.

Thanks!

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 07 Nov 2007 10:29

You can setup your SSH client for port forwarding in the following way:
ssh -L SourcePort:WebServerHost:80 username:SSHServerHost,
where
SourcePort - local port number, which will be listened (e.g. 5001);
UserName - user name for SSH connetion.
After that setup your Web client to connection to SourcePort on localhost.

apple12
Posts: 6
Joined: Tue 06 Nov 2007 02:14

Post by apple12 » Fri 09 Nov 2007 07:36

Could you give me sample code to show how to make port forward from SSH Server to Web Server using SSH Client?

I do not understand how to make port forwarding using SSH Client.

Thanks!

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 12 Nov 2007 08:02

What do you mean under port forwarding?
Why the previous schema does not satisfy your needs?

apple12
Posts: 6
Joined: Tue 06 Nov 2007 02:14

Post by apple12 » Mon 12 Nov 2007 09:17

I have a simple Web Server. Before Web Server, I add the SSH Server (develop with securebridge ScSSHServer)

When file pass through SSH Server, I want the files go to web server.
Since I use ScSSHServer which do not have port forwarding, how can I transfer the file to Web server?

I have checked ScSSHClient can make port forwarding but not to ScSSHServer.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 14 Nov 2007 15:00

If you want an SSH server to transfer data to another addressee, you have to send data to the SSH server by an SSH client with settings like described above. Data between SSH Client and SSH server is transferred in an encrypted form.

If you just need to forward data from one port to another port, you should not use SecureBridge. You just need to write a program that receives data from the first port and writes it to another port.

Post Reply