File transfer

Hi All,

it might not be an sound question,

i have two server like A and B..
i want to transfer file from B to A
..here i have some questions..

1) do we need to create private and public key to connect..and
transferring files...from B to A..?
2) i tried with scp options like below...but no luck..:slight_smile:

i ran below command from server B ..to transfer file.txt to server A

scp file.txt user@ipaddress\(serverA) /location/severB/

any suggesstion...plz..?

Thanks
Sha

There are tons of howtos on the web for this. You will have problems not stumble over one if you would search. There is also a search function for this forum.

Have you already setup SSH for the respective user on each machine?

If not, log int each machine and run this command: ssh-keygen
(Do man ssh-keygen for more information.) It will create keys in ~/.ssh.

I find the simplest thing to do at this point is to copy the .pub files to some easily-accessible common location (secrecy is not needed for the .pub files, so it could be a publicly available site) such as a shared drive or ftp server (or a USB key) and then fetch them onto the opposite machines and append them to .ssh/authorized_keys.

That is, on machine A, copy ~/.ssh/id_dsa.pub somewhere as A_id_dsa.pub. And on machine B, copy ~/.ssh/id_dsa.pub as B_id_dsa.pub.

Then on machine A do this:
cat B_id_dsa.pub >> ~/.ssh/authorized_keys
And on machine B do this:
cat A_id_dsa.pub >> ~/.ssh/authorized_keys

You could do the same for the other .pub files, but I never bother with them.

At that point, you should be able to use scp.

If it still fails, you can try renaming or even deleting ~.ssh/known_hosts on each machine. Information is stored it it when you make contact the first time and that may inhibit future connections if anything changes (like a dynamic IP address).

You can also experiment with ~/.ssh/config (see man ssh_config).