Validating scp connection

Hi Team,

I have 2 servers Server-A & Server-B.

Is there any way to test scp connection between Server-A & Server-B without transferring file?

Basically i want to test the availability of scp connection..

Thanks in advance...

I would actually go the whole way and create a "Hello" type file with the expected permissions and actually copy it. That way you can be sure that you are able to navigate to the correct area and the get what will be the required files.

I hope that this thought helps,
Robin

@rbatte1 Thanks for your response. But i am looking for a way to test scp without transferring file.

scp stands for "secure copy", so how else but by copying do you think you could test it?

scp is a member of the ssh familiy, so if e.g. an ssh login attempt works, the probability of scp working is high.

If ssh works, then scp works as well.

  • You could test if port 22 exists, for example using telnet
  • You could test with ssh if you can do a remote execution, for example a NOP ( : )
    text ssh Server-B :
  • You could see if the remote directory you intend to copy to is writeable (if the dir is on a RW-filesystem)
    text ssh Server-B '[ -w /path/to/dir ]'

My suggestion to create a dummy file was to check the other parts of the process, not just the secure connection so that you can be sure you are getting to the right path and that the id you connect with can actually read a file with the same permissions. Without that, you are not really testing it properly.

It doesn't have to be a large file if you are worried about the network traffic and time.

Can I presume that you are building up a remote path/filename in your script? If so, are you sure you can get to it? That is the point of testing with a dummy file.

Robin

We are actually creating a script to validate scp conn. So if i create a test file and transfer means there are chances of some invalid files in the target servers.

I don't want to trouble the targer servers for our testing...