Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 550
  • Last Modified:

How do I in shell terminal copy an entire file or directory file from one linux server to anouther linux server

Ok I have centos os account on one server and I want to pull in my files from another server.

I want to do this in terminal mode. By ssh into the remote server getting my entire directory and copying it to my current location.
How would I do this
0
sobeservices2
Asked:
sobeservices2
  • 4
  • 3
  • 2
  • +1
4 Solutions
 
medveddCommented:
scp -r user@host:/path/dir .

user - your username on remote server host
0
 
JelcinCommented:
you can use scp

scp root@192.168.178.1:/directory/file /local/directory/

would login on remote server 192.168.178.1 with user root and copy /directory/file from remote server to /local/directory/
0
 
JelcinCommented:
scp file  root@192.168.178.1:/directory/

would copy file on local computer to server 192.168.178.1 with user root to /directory/
0
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

 
sobeservices2Author Commented:
I am trying to copy the home directory

would path be

/home/myname
usr/home/myname
I want everything from the home directory
0
 
sobeservices2Author Commented:
scp root@192.168.178.1:/directory/file /local/directory/

Worked how would I eliminate hidden files?
0
 
rajendraoneCommented:
scp root@192.168.178.1:/directory/[^.]* /local/directory/

The expression [^.]* means any files that does not start with "." which are hidden.

0
 
sobeservices2Author Commented:
Thank you
0
 
sobeservices2Author Commented:
I tried this with another vm machine Solaris 10

and got this when I typed the line

ssh: connect to host columbia.com port22: Connection refused

What does this mean it worked ok on another vm
0
 
rajendraoneCommented:
That means columbia.com is not listening on port 22 or you cannot reach at port 22 of the server. It could be reachability issues or just the server is not listening to that port for anyone. Make sure sshd is running on the remote server.
You may verify if the server is listening to ssh by issueing following command:
$ netstat -na | grep 22
      *.22                 *.*                0      0 49152      0 LISTEN
If you see something like *.22 then it is listening on port 22.

First make sure you can ping to that server.
0
 
rajendraoneCommented:
Or sometimes, even when ssh is running you are not allowed ssh using root. Check /etc/ssh/sshd_config file at the remote server.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now