Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

File transfer over SSH onto linux server from hard disk on remote MAC

Discussion in 'Getting Started' started by Sonal, May 23, 2017.

  1. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    Hi, I have 1.96 TB sized folder on a hard disk and I want to upload it to the server from my MAC PC using SSH. What is the quickest and effective way to do it?


     
  2. Steve

    Steve New Member

    Joined:
    Apr 25, 2017
    Messages:
    9
    Likes Received:
    10
    If you are wanting to use SSH/internet to do it, you're looking at rsync (or scp - I'd choose rsync). Usage:

    rsync -Paz /path/to/your/source/directory [email protected]:/path/to/destination/

    Note: if your source is the directory name without a trailing /, it will transfer the directory too. If you include the trailing / for the source directory, it will transfer the contents of the directory. (rsync -Paz asdf [email protected]:~ will transfer directory to /home/user/asdf, rsync -Paz asdf/ [email protected]:~ will transfer everything inside of asdf into /home/user/ and not create the asdf directory)

    Switches: -P = --progress and --partial, -a == --archive, -z == use compression. Depending on your file types (JPG, MP4, EXE, stuff that doesn't compress well), this might actually hurt your overall performance by 1%.
     
    Rob likes this.
  3. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    @Steve. Thank you for your response. I tried this option but gives below error. I assume the connection to server is not established

    ssh: connect to host _IP port 22: Operation timed out
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [sender=2.6.9]
     
  4. Steve

    Steve New Member

    Joined:
    Apr 25, 2017
    Messages:
    9
    Likes Received:
    10
    "ssh: connect to host _IP port 22: Operation timed out" -- means that you're not able to connect to it via SSH on port 22. If you're running on a different port, you'd need to tweak the rsync line to something like:
    Code:
    rsync -Paz -e "ssh -p xxxx" /path/to/source [email protected]:/path/to/dest/"
    What's your command to SSH into the destination? (remove username and IP/host for security, plzkthx)
     
  5. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    rsync -Paz /Path_to_Source [email protected]:/Path_to_Destination
     
  6. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    397
    Try telnetting to port 22 of your server to see if it's open.. should see something like:
    Code:
    telnet linux.org 22
    Trying 107.170.33.185...
    Connected to linux.org.
    Escape character is '^]'.
    SSH-2.0-OpenSSH_5.3
     
  7. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    @Rob: The port is Open.

    telnet linux.org 22

    Trying 107.170.33.185...

    Connected to linux.org.

    Escape character is '^]'.

    SSH-2.0-OpenSSH_5.3
     
  8. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    397
    well, replace `linux.org` with your hostname or IP address..

    Rob
     
  9. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    @Steve : Pardon me if the question is silly as I am really new to linux.
    What is XXXX in your command. Is the port no. I am still not able to connect.
     
  10. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    397
    Yes, he's using xxxx as the port..

    If your server is using the default SSH port, it's 22 and you don't have to specify it, but if it's 2222 or something, then you'd use this command, assuming you're connecting as sonal @ example.com:

    Code:
    rsync -Paz -e "ssh -p 2222" /path/to/source [email protected]:/path/to/dest/
     
    Steve likes this.
  11. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    I can't connect to host.

    telnet: connect to address IP: Operation timed out

    telnet: Unable to connect to remote host
     
  12. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0

    Well, it works with username not with IP my bad. :p
     
  13. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    397
    Ok, and your server is online currently I'm assuming :)

    I'd call your host and ensure ssh is enabled and inquire which port it's operating on.. also ensure you have shell access as some hosts disable it on a user level as well.

    Rob
     
  14. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    rsync -Paz /Path_to_Source [email protected]:/Path_to_destination. It stops unexpectedly but gives error

    file has vanished: "/Path_to_source/Part_2/2017-05-15-12-17-15-File110743.sgd"
    rsync: readdir("/Path_to_Source"): Input/output error (5)
    106703 files to consider
    rsync: connection unexpectedly closed (8 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [sender=2.6.9]
     
  15. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    397
    Can you confirm that you can SSH in with the same user/pass?
     
  16. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0

    Yes i can ssh with the same user. The error shows with the file/s in the folder I am trying to copy.
     
  17. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    397
    Can you try putting into your home directory? Instead of /path/to/dest/, use '~/' (without quotes)

    I'm on mobile right now so hoping you understand :)
     
  18. Steve

    Steve New Member

    Joined:
    Apr 25, 2017
    Messages:
    9
    Likes Received:
    10
    OK, you've been able to start over SSH, but it times out. Try without the "z" as well - I've had some issues when trying to transfer a large number of files to another location timing out. And if that doesn't work, you might need to edit on the server the /etc/ssh/sshd.conf file (I think that's the location/file) and change the timeout to something larger and restart sshd.
     
  19. Sonal

    Sonal New Member

    Joined:
    May 23, 2017
    Messages:
    20
    Likes Received:
    0
    So it starts building the file list and then stops and gives below error.


    rsync: connection unexpectedly closed (8 bytes received so far) [sender]

    rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [sender=2.6.9]
     
  20. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    145
    Likes Received:
    397
    Make sure your remote path exists.. this error can pop up in this case as well.

    Code:
    .... [email protected]:~/
     

Share This Page