Need some help regarding file transfer between server (sftp/scp)


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Need some help regarding file transfer between server (sftp/scp)

Hi All,

Need some help regarding file transfer between server.

Suppose we have system-A and system-B. To transfer file from system-A to system-B we usually share the
public keys of system-A to system-B and do scp/sftp to transfer a file.

Is it possible that public key of system-B can be shared to system-A, so that the system-A can establish connectivity to system-B via scp/sftp or using jdbc(java).? Is this even possible?

Thanks in advance.

Moderator's Comments:
Mod Comment Corrected spelling mistakes.

Last edited by RavinderSingh13; 07-29-2019 at 07:39 AM..
# 2  
Quote:
Originally Posted by abhi_123
Is it possible that public key of system-B can be shared to system-A, so that the system-A can establish connectivity to system-B via scp/sftp or using jdbc(java).? Is this even possible?
Yes, it is possible and yes, such a public key is valid for scp-, sftp- and ssh-connections. I don't know if jdbc can use the same key, however.

scp, ssh and sftp all share the same protocol (SSL, secure socket layer) and the keys you exchange are the keys for the protocol, not the application on top of it, therefore the keys are valid for all (or none) of them.

A "key" is exactly what it name suggests: on a system (let us call it "server") in the home of a specific user (call it "serveruser") we put a key of the user "clientuser" from "client". From now on an incoming connection from "clientuser@client" to "serveruser@server" is authenticated via the key instead of a password.

Two things to keep in mind: first, authentication is a directed thing: if "clientuser@client" is allowed access as "serveruser@server" that does NOT mean "serveruser@server" is allowed access as "clientuser@client". It is possible to set that up but these are two different keys placed in two different places where "source" and "target" are reversed. Each of these keys allow for a one-way authentication. (If i give you the keys to my house it does not mean i could enter yours too - you would also have to give me your keys for that.)

Second: all these protocols work in a client-server model. That means for i.e. the ssh connection to work the ssh-daemon has to run on the server side. What the "server" and what the "client" is is determined by the sort of connection, not the system! Trying to log on from system A to system B means A is client, B is server. Trying to log on from B to A reverses these roles, so in the first connection B has to have the daemon running, in the second one it has to be A.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Thank you Bakunin.
Few clarifications...
But in such a case, when we share a public key from server/system B to server/system A, this generally indicates that user from server B is transferring files to server A and not vice-versa.
Can user from server A connect to server B using this public key. If so then how will the authentication will happen between servers.

We usually use scp -i <pvt_key> <obsolute_path_of_dummy file> user@host or sftp user@host to connect a server. Then is there no need to mention the private key in scp to connect from server A connect to server B?
Also what would be the scp/sftp syntax.

Thank you

Last edited by rbatte1; 07-31-2019 at 08:12 AM..
# 4  
Quote:
Originally Posted by abhi_123
But in such a case, when we share a public key from server/system B to server/system A, this generally indicates that user from server B is transferring files to server A and not vice-versa.
No! It means that the authentication is done in this direction.

Consider it this way: if you give someone the key to your house he has access to it. That could mean he takes away something or brings something, but this difference is not depending on him receiving your key or not. He could do both these things without the key too, he just would have to ring your bell (and wait till you answer it) if he lacks the key.

If userA@systemA (notice that "userA" on one system and "userA" on another system are two different accounts, they just happen to share the same name) has his key on systemB this user is allowed to log on (without password). What he does after this logon is not determined by the key at all. He could put files (that is: transfer to the server) or get files (that is: copy files from that server).

This is also possible with classical ftp or sftp: there is the put/mput command to move files to the system and get/mget command to move/copy files from the system.

In scp this would look like:

Code:
scp user@system:/path/to/remotefile /path/to/localfile

This will transfer a remote file from "system" using the account "user" to the local system. The other way would be:

Code:
scp /path/to/localfile user@system:/path/to/remotefile

This would transfer a local file using the account "user" to the remote system "system". The difference between having put the key of your local user on "system" will be: without the key you need to authenticate, with the key you don't.

I hope this helps.

bakunin
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #757
Difficulty: Medium
The MOSFET is the least common semiconductor device in digital and analog circuits.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

SCP File Transfer

On unix AIX server, when I am trying to transfer file from one directory to another directory on the same server through a program(where i call the script) it gives error "Lost Connection". (5 Replies)
Discussion started by: Pash
5 Replies

2. UNIX for Advanced & Expert Users

SCP File Transfer

I have 3 AIX server namely - Server 1 , Server 2 and Server 3. And have done SCP setup between Server 1 and Server 2 so that i dont have to give password when i transfer file from Server 1 to Server 2 by setting public key between the server. Q1. If the unix password of the target server... (3 Replies)
Discussion started by: Pash
3 Replies

3. Shell Programming and Scripting

Transfer files from linux server to windows using secure ftp (sftp)

HI, I have to transfer files from linux server to windows using secure ftp (sftp) .Kindly help me out. (3 Replies)
Discussion started by: manushi88
3 Replies

4. Shell Programming and Scripting

Using SFTP and FTP to transfer data from One Remote Server To Another

HI I need to write a script in 415univ server which should go to 534unix server and move the files from there to windows server. I am not able to get it bcoz sftp prompt is not allowing ftp command. Can some one plz help me Thanks in advance (3 Replies)
Discussion started by: himakiran9
3 Replies

5. Shell Programming and Scripting

SFTP to transfer files from one server to another

Hello, i have to write a script to perform sftp from the remote server to another server. the files which are at the remote location are huge data log files which should be transfered to my server in a particular folder. could you please provide me the general code (simple )... (1 Reply)
Discussion started by: urfrnddpk
1 Replies

6. UNIX for Dummies Questions & Answers

File transfer using SCP

I have a shell script which uses SCP command to transfer the files from one server to another server. The files are getting transferred successfully, but the problem is the files transferred to the destination server didnot have the permissions as that of the files on the source server. Command... (5 Replies)
Discussion started by: kumarm
5 Replies

7. Shell Programming and Scripting

file transfer using scp..

Hi Frdz I have a problem like. I need to transfer a file from source to destination (different systems with different IPs) using "scp" command and before transfer the file i have to check the file is available in destination or not, if it is there no need to transfer, otherwise we have to... (5 Replies)
Discussion started by: KiranKumarKarre
5 Replies

8. UNIX for Dummies Questions & Answers

scp or sftp to Window server

Dear Unix Gurus, I have a question to confirm before I proceed to script my program. I'm currently running on IBM AIX Ver 5.3. I just like to know if it's compatible to use scp or sftp between AIX and Wintel server? I'm trying to scp or sftp a file from AIX to Window server and I was... (1 Reply)
Discussion started by: lweegp
1 Replies

9. UNIX for Dummies Questions & Answers

File Missing When Grabbing Files from SFTP Server using SCP Command

Hi, I have this problem where sometimes my files would go missing when I schedule my crontab to run the SCP command to get file from the SFTP server. My crontab will run the scripts at an interval of 3 minutes (between the two scripts) The following is the setting in my crontab. ... (1 Reply)
Discussion started by: gingervitus
1 Replies

10. AIX

CRLF during SFTP transfer is appearing only in one server

Hello. I have got 3 unix boxes A B C. Box A is being used to prepare some reports. After the reports generation, Box A sftp the reports to Box B and Box C. When I look at the report in Box B and Box C. The reports are different. In Box B, I see using od -x command there is CRLF (\r\n) at the end... (7 Replies)
Discussion started by: panchpan
7 Replies

Featured Tech Videos