LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Transfer file from one server to other (https://www.linuxquestions.org/questions/linux-networking-3/transfer-file-from-one-server-to-other-940601/)

Muhammad Awais 04-19-2012 02:41 AM

Transfer file from one server to other
 
Hi i want to know is there any command to transfer file from one server to a local machine in our office.

For example our server is 88.44.44.55 and our router's ip is 66.33.22.11 and my local ip is 192.168.1.1,
Now i want to transfer file from 88.44.44.55 to my own linux machine 192.168.1.1.

Is it possible???

Thanx In Advance

acid_kewpie 04-19-2012 02:45 AM

of course it's possible. I'd suggest scp to start with as the simplest way. Obviously you need to be able to reach one machine from the other first.

Muhammad Awais 04-19-2012 02:47 AM

Thanx acid_kewpie
This 88.44.44.55 ip is provided by our broadband service provider.
Can u please give me example of command line in linux???

Muhammad Awais 04-19-2012 02:48 AM

I want to write a script to automatically download backup from our server.

pan64 04-19-2012 02:51 AM

there are a lot of solutions, but mainly they are a pair of client-server applications.
So you can try scp, ftp, rsync, wget (these are the clients to work with), but all of them require a server (or at least some configuration) on the other side.
In general office can restrict the outgoing traffic and block incoming, so you need to set a server at home and run the client in the office. The router also should be configured to redirect the requests to your host.

acid_kewpie 04-19-2012 02:52 AM

I'm sure you can read the scp manpage for this, it's not hard to look up.

scp user@destination:/where/the/file/is/file.txt /where/the/file/goes

Muhammad Awais 04-19-2012 02:55 AM

In destination which ip should b giver the local machine ip or 88.44.44.55?
When i paste 88.44.44.55 the reply is
ssh: connect to host 88.44.44.55 port 22: No route to host
lost connection

acid_kewpie 04-19-2012 02:57 AM

We have no idea how your network is set up do we? give us some useful information to start with and we can try to work it out. but it's a big jump from having possibly no connectivity to copying a file, so work out what your current problem is first, before trying to fix an unrelated one.

Muhammad Awais 04-19-2012 03:04 AM

We download Backups from our server daily. Log files of radius and asterisk.
I want to write a script which automatically download files on our computer, Our server is in Germany and our office is located in Pakistan.
the service provider gives us 88.44.44.55 ip, and our backup computer which save backup have ip 192.168.1.1, now i want to transfer backup directly to our backup computer.
i m using this command scp blackup.out root@88.44.44.55: /root
but i m getting this error
ssh: connect to host 88.44.44.55 port 22: No route to host
lost connection

acid_kewpie 04-19-2012 03:05 AM

ok, that's repeating the stuff we DO know. how about the stuff we DON'T know? where does this public IP fit into it? Is internet involved etc..? what is the layout of your network? What security devices are involved? What device does this public IP reside on?

pan64 04-19-2012 03:13 AM

you can try traceroute 88.44.44.55 for example

Muhammad Awais 04-19-2012 03:26 AM

traceroute to 58.65.154.78 (88.44.44.55), 30 hops max, 40 byte packets
1 xx6651142097.cipherkey.com (66.55.44.97) 0.577 ms 0.593 ms 0.645 ms
2 xx208110096072.cipherkey.com (208.110.96.72) 0.264 ms 0.211 ms 0.194 ms
3 ge-6-10-340.car3.seattle1.level3.net (4.71.152.129) 4.955 ms 4.872 ms 4.858 ms
4 ae-32-52.ebr2.seattle1.level3.net (4.69.147.182) 11.157 ms 11.168 ms 11.124 ms
5 ae-2-2.ebr2.denver1.level3.net (4.69.132.54) 30.918 ms 31.172 ms 31.033 ms
6 ae-3-3.ebr1.chicago2.level3.net (4.69.132.62) 55.964 ms 55.760 ms 55.861 ms
7 ae-1-100.ebr2.chicago2.level3.net (4.69.132.114) 56.063 ms 56.006 ms 66.339 ms
8 ae-6-6.ebr2.washington12.level3.net (4.69.148.145) 76.714 ms 74.675 ms 70.754 ms
9 ae-5-5.ebr2.washington1.level3.net (4.69.143.221) 70.921 ms 70.751 ms 70.549 ms
10 ae-41-41.ebr2.paris1.level3.net (4.69.137.49) 150.292 ms ae-42-42.ebr2.paris1.level3.net (4.69.137.53) 150.588 ms 150.081 ms
11 ae-22-22.ebr1.paris1.level3.net (4.69.143.121) 150.438 ms 149.545 ms 150.298 ms
12 ae-1-7.bar1.marseille1.level3.net (4.69.143.237) 159.758 ms 160.404 ms 161.215 ms
13 ae-2-3.edge2.marseille1.level3.net (4.69.143.250) 160.401 ms 162.066 ms 160.738 ms
14 213.242.115.6 (213.242.115.6) 271.851 ms 213.242.115.2 (213.242.115.2) 272.715 ms 272.762 ms
15 static-10ge-khi494-p01-khi494-swb.pie.net.pk (202.125.128.157) 271.800 ms 270.202 ms 270.390 ms
16 rwp44.pie.net.pk (221.120.254.5) 294.432 ms 291.254 ms 292.492 ms
17 rwp44.pie.net.pk (221.120.253.10) 293.783 ms 293.879 ms 292.322 ms
18 rwp44.pie.net.pk (221.120.237.102) 301.394 ms 301.483 ms 292.447 ms
19 mbl-65-154-78.dsl.net.pk (88.44.44.55) 293.415 ms 293.367 ms 293.744 ms


This is the reply

acid_kewpie 04-19-2012 03:30 AM

so what IS 88.44.44.55?

Muhammad Awais 04-19-2012 03:32 AM

This ip is assign to us by our internet provider.
Internet is involved.

pan64 04-19-2012 03:33 AM

I would try a port scan, which ports are open, what can you reach from the other side?
do you know nmap?

Muhammad Awais 04-19-2012 03:35 AM

No i dont know, Basically i m new on linux :(

acid_kewpie 04-19-2012 03:39 AM

Quote:

Originally Posted by Muhammad Awais (Post 4656997)
This ip is assign to us by our internet provider.
Internet is involved.

No, is it on the server? A firewall?

You're REALLY making us work FAR too hard for this...

Muhammad Awais 04-19-2012 03:40 AM

This is server

pan64 04-19-2012 03:47 AM

What is the result of nmap -p1-10000 -T4 -sS 88.44.44.55

acid_kewpie 04-19-2012 03:47 AM

Hmm, ok so putting your server directly on the net is a REALLY bad idea... you should change that. Unless this is some one off hosted service.

But at least it should make it simple, and you should only need to open port 22 to that interface and go off from there. What distro is the server? You can show us your iptables output ("iptables -vnL") and also actually confirm that ssh is running with a "netstat -plnt".

How do you get into this box at present if you can't ssh to it?

Muhammad Awais 04-19-2012 03:51 AM

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-04-19 01:48 EDT
Interesting ports on mbl-65-154-78.dsl.net.pk (88.44.44.55):
Not shown: 9984 closed ports
PORT STATE SERVICE
20/tcp filtered ftp-data
21/tcp filtered ftp
22/tcp filtered ssh
23/tcp filtered telnet
53/tcp open domain
80/tcp open http
123/tcp filtered ntp
443/tcp filtered https
3306/tcp filtered mysql
3389/tcp filtered ms-term-serv
6080/tcp filtered unknown
7070/tcp filtered realserver
7554/tcp filtered unknown
8000/tcp filtered http-alt
8080/tcp filtered http-proxy
9554/tcp filtered unknown

Nmap finished: 1 IP address (1 host up) scanned in 117.442 seconds

descendant_command 04-19-2012 04:01 AM

So 88.44.44.55 is the public IP of your router in Pakistan?

Muhammad Awais 04-19-2012 04:02 AM

Yes sir...

Muhammad Awais 04-19-2012 04:04 AM

Chain INPUT (policy ACCEPT 33 packets, 3561 bytes)
pkts bytes target prot opt in out source destination
33 3561 asterisk all -- * * 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 asterisk all -- * * 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT 32 packets, 3230 bytes)
pkts bytes target prot opt in out source destination

Chain asterisk (2 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- * * 178.33.62.28 0.0.0.0/0
0 0 DROP all -- * * 37.58.74.106 0.0.0.0/0



Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 2752/./hpiod
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2875/mysqld
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 2792/xinetd
tcp 0 0 0.0.0.0:5038 0.0.0.0:* LISTEN 2975/asterisk
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2486/portmap
tcp 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN 2975/asterisk
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 3194/Xorg
tcp 0 0 0.0.0.0:1008 0.0.0.0:* LISTEN 2522/rpc.statd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2770/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2779/cupsd
tcp 0 0 0.0.0.0:1720 0.0.0.0:* LISTEN 2975/asterisk
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2908/sendmail
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN 2757/python
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 7912/java
tcp 0 0 :::8009 :::* LISTEN 7912/java
tcp 0 0 :::8080 :::* LISTEN 7912/java
tcp 0 0 :::6000 :::* LISTEN 3194/Xorg
tcp 0 0 :::80 :::* LISTEN 2936/httpd
tcp 0 0 :::22 :::* LISTEN 2770/sshd
tcp 0 0 :::443 :::* LISTEN 2936/httpd

acid_kewpie 04-19-2012 04:06 AM

Quote:

Originally Posted by descendant_command (Post 4657039)
So 88.44.44.55 is the public IP of your router in Pakistan?

Yes sir?? You just said it was your server... I give up.

Muhammad Awais 04-19-2012 04:10 AM

Sorry i just waste lot of ur time...

88.44.44.55 This is our server that is in Germany.
66.33.22.11 This the public IP of our router in Pakistan.
192.168.1.1 This is my computer's IP.

descendant_command 04-19-2012 04:12 AM

So you have ssh access to your server in germany to download your logs manually?
I assume yes so ...

The command to schedule on your client machine would be
Code:

you@client:-$ scp user@server:/path/to/logfile /local/path/to/put/logfile
You can find out about key-based ssh authentication so you don't need to type your password each time.

Muhammad Awais 04-19-2012 04:16 AM

Should i run this command on our server???

Muhammad Awais 04-19-2012 04:17 AM

I need a command which i run on 88.44.44.55 and backup downloaded on 192.168.1.1.

descendant_command 04-19-2012 04:18 AM

No, you run it on your client.

---------- Post added 04-19-12 at 09:18 PM ----------

Quote:

Originally Posted by Muhammad Awais (Post 4657067)
I need a command which i run on 88.44.44.55 and backup downloaded on 192.168.1.1.

Why?
You are having enough trouble doing it the easy way...

Muhammad Awais 04-19-2012 04:22 AM

Because i made a script which automatically make .tar.gz file and i want to add this command so after completing the compression it download the file...

descendant_command 04-19-2012 04:30 AM

OK.
Presumably you have a static public IP in Pakistan?
If not, then it won't work if your IP keeps changing every few days...
So you will need to set up ssh-server on your Pakistan machine, along with key-based auth, and forward an appropriate port (probably NOT 22 would be best) on your router.

Muhammad Awais 04-19-2012 04:33 AM

Our ip is static.
Can u please explain the procedure little bit.

descendant_command 04-19-2012 04:39 AM

I just did.

joker20 04-19-2012 02:01 PM

clearly someone needs their hand held so let me see if i can put an end to all of this madness.
you want to scp a tarball from your server to your workstation (its easier to do it vice versa but whatever)

client config:
you'll need to setup an openssh server on your workstation (ill leave that up to you to figure out)
make sure openssh is started, a quick way to determine this is to do `nmap localhost` - look for 22 OPEN
if you're running iptables or some kind of firewall you'll also need to make sure port 22 is accepted/permitted

router:
im not sure what kind of router you have in Germany but either way you'll need to setup port forwarding (nat statements) TO your workstation on port 22

server:
if you can ssh from your server to your workstation then you'll obviously see traffic is working as it should.
from here you'll need to set up a key pair so you can ssh without a password as noted earlier in this thread. a good tutorial of this is here http://www.thegeekstuff.com/2008/11/...n-ssh-copy-id/
if you've made it this far and everything is working like it should you can no go ahead with whatever method you want to use to transfer your files

you@server:-$ scp user@client:/path/to/logfile /local/path/to/put/logfile

a cron job w/ scp would be a good option

the rest is up to you...

descendant_command 04-19-2012 03:07 PM

Quote:

Originally Posted by joker20 (Post 4657622)
you@server:-$ scp user@client:/path/to/logfile /local/path/to/put/logfile

In the interest of NOT overwriting the server log with the old copy from the workstation, this should be
Code:

you@server:-$ scp /local/path/to/logfile user@client:/remote/path/to/put/logfile

joker20 04-19-2012 03:12 PM

Quote:

Originally Posted by descendant_command (Post 4657709)
In the interest of NOT overwriting the server log with the old copy from the workstation, this should be
Code:

you@server:-$ scp /local/path/to/logfile user@client:/remote/path/to/put/logfile

ah, thanks for that - i copied that syntax from someone elses post above me and just swapped server for client without fixing the rest hahaha, but ya thats what it should look like

Muhammad Awais 04-19-2012 10:37 PM

Thanx Every one, Problem Solved :)


All times are GMT -5. The time now is 03:34 AM.