FTP server: How to send response to FTP command like SYST in active mode? - iis

I am implementing an FTP server. Suppose a client sends PORT command first. Then it sends SYST command. To which port should I send the response?
The client port from which SYST command is received
The client port specified in PORT command?
Please advise.

PORT command (as well as PASV, EPRT and EPSV), affect data connections only. SYST command, as well as majority of FTP commands, make no use of the data connection. A data connection is used by RETR, STOR, LIST and similar commands only.
So PORT (and the others) have no effect on SYST. You process SYST the same way, as if no PORT command was used: You send the response to the same connection, from which you have received the SYST command.

Related

Sending a file from a server to a client connected via VPN

I connect my client laptop to a server via VPN and be able to send a file from the client to the server using the "scp" command.
Now, I want to send a file from the server back to the client using the "scp" command, but I got a permission denied message. I believe I have to setup a publickey of the sender on the receiver first before doing this, but whose publickey? Is it the VPN server's publickey or the server's publickey?
I have got an answer. I can simply run the "scp" command on the remote client to copy file from the server. I was trying to make thing complicate by trying to run scp command on the server, which is unnecessary and stupid.

Server - client communication on the same host

I'm writting a program that simulates nodes in network. Every node is listening to some port on local for incoming requests. If a request is received it replies to sender of the request. The reply is sent after a socket is created associated with the address of the sender of the request. Since sender is using some port on localhost and has used bind to listen to id, trying to bind to the same port with an other process results in a messages that states that the port is already taken (bound).
How should I solve this in order to be able to simulate server/client on the same machine? I am using UDP protocol for this program.
You solve this by using different ports for client and server interaction. A useful example would be how client and server interact during DHCP. The client sends requests via UDP on port 67 and the server sends responses back via UDP on port 68.

shutdown dynamically created putty ssh tunnel

We have a windows program. This program performs a soap request to a server in our DMZ
(it is a direct HTTP request to - let's say 192.168.100.10).
Now - for security reasons, we have to change the setting. The request should go via a secure
channel to the server.
The future workflow has to be the following:
Before we start the SOAP request, we have to call "putty.exe" with special parameters in order to dynamically create a secure tunnel.
putty.exe -L 5510:192.168.100.10:8080 -l user1 -i c:\private_key.ppk 192.168.100.10
After this we perform the soap request to "localhost:5510". The dynamically created secure tunnel will foward the packets of the request through the ssh channel to the web server of 192.168.100.10. The response will come the same way back.
After a list of maybe 500 requests have been performed, the secure tunnel should be closed and the program should be ended.
Apart from getting the process id of the putty process and killing the process, is there any other way to close the putty secure ssh tunnel?
Thanks alot in advance

linux command to connect to another server using hostname and port number

what is the Linux command to connect to another server using host name and port number?
how to connect to another server using only host name and port number then check if an existing process is running? the only way i see it working is to log in to the server and run the PS command. but is there a way to do it without logging in directly to the other server and connect only with host name and port number and check the running process?
If you just want to try an arbitrary connection to a given host/port combination, you could try one nmap, telnet or nc (netcat).
Note that you can't necessarily determine whether or not a process is running remotely - it might be running on that port, but simply ignore anything it sees over the port. To really be sure, you will need to run ps or netstat or etc. via ssh or etc.
If you want to use SSH from e.g. a script or, more generally, without typing in login information, then you will want to use public key authentication. Ubuntu has some good documentation on how to set this up, and it's very much applicable to other distrobutions as well: https://help.ubuntu.com/community/SSH/OpenSSH/Keys.
If you have no access to the server you're trying to list processes on at all, then I'm afraid there isn't a way to list running processes remotely (besides remote tools like nmap and so on, as mentioned earlier - you can always probe public ports without authentication [although you might make people angry if you do this to servers you don't own]). This is a feature, not a problem.
telnet connects to most of services. With it you can ensure that port is open and see hello message (if any). Also nc is more low level.
eri#eri-macro ~ $ telnet smtp.yandex.ru 25
Trying 87.250.250.38...
Connected to smtp.yandex.ru.
Escape character is '^]'.
220 smtp16.mail.yandex.net ESMTP (Want to use Yandex.Mail for your domain? Visit http://pdd.yandex.ru)
helo
501 5.5.4 HELO requires domain address.
HELO ya.ru
250 smtp16.mail.yandex.net
MAILĀ FROM: <someusername#somecompany.ru>
502 5.5.2 Syntax error, command unrecognized.
If there is plain text protocol you cat talk with service by keyboard. If connection is secured try openssl.
openssl s_client -quiet -connect www.google.com:443
depth=1 /C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
verify error:num=20:unable to get local issuer certificate
verify return:0
GET /
<HTML><HEAD>
If protocol is not known you may see much of hieroglyphs or just Connected to ... message.
Try this :
ssh <YOUR_HOST_NAME> 'ps auxwww'
Like Dark Falcon said in the comments, you need a protocol to communicate with the server, a port alone is useless in this case.
By default on unix (and unix like) servers, ssh is the way to go.
Remote Shell with this command. Example is cat a file on the remote machine.
rsh host port 'cat remotefile' >> localfile
host and port self explainitory
remotefile: name of some file on the machine remote logging to in home directory
localfile: name of file cat information to.
Use monitoring software (like Nagios). It looks at your processes, sensors, load and thatever you configured to watch. It continuously stores log. It alerts you by email\sms\jabber if something fails. You can access it with browser or by HTTP API.

HTTP XML data through SSH on port 8080

I have deployed a web service which should receive XML data on port 8080. The other service is pushing this data from the remote host.
But as for my server, it has only a local IP-address. I can access it only with ssh from outside. When I asked the administrator, he said that HTTP-data pushing should be done through ssh tunnel.
The question is - how is it possbile to do? How can I configure the local server to receive XML data with HTTP through SSH? And what is the common way to do that?
Try this from sender :
ssh <ssh_username>#<yourserverip> -L 7070:localhost:8080 -N
Then, if you send XML data to "localhost:7070", data will be redirected to port 8080 of 'yourserverip'. If your server has a SSH daemon running, there is nothing to do on server side.
More information : http://www.debianadmin.com/howto-use-ssh-local-and-remote-port-forwarding.html

Resources