Page 1 of 1

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

Posted: Tue 06 Nov 2007 02:23
by apple12
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!

Posted: Tue 06 Nov 2007 15:04
by Dimon
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.

Posted: Wed 07 Nov 2007 01:43
by apple12
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.

Posted: Wed 07 Nov 2007 03:20
by apple12
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!

Posted: Wed 07 Nov 2007 08:07
by Dimon
Please specify, what Web client and what SSH client do you use.

Posted: Wed 07 Nov 2007 08:45
by apple12
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!

Posted: Wed 07 Nov 2007 10:29
by Dimon
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.

Posted: Fri 09 Nov 2007 07:36
by apple12
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!

Posted: Mon 12 Nov 2007 08:02
by Dimon
What do you mean under port forwarding?
Why the previous schema does not satisfy your needs?

Posted: Mon 12 Nov 2007 09:17
by apple12
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.

Posted: Wed 14 Nov 2007 15:00
by Dimon
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.