How do I copy data from a Ubuntu server using terminal by telnet?

11,356

Solution 1

You can use scp if you have an ssh server running on the remote machine (a good thing to have anyway). Telnet is not good, its unencrypted and bothersome.

Since I assume you can ssh onto the remote machine, the basic way to use scp is:

scp -r ~/www/html/js qa@desktop2:~/home/qa/html/js

Assuming that you want to copy from qa@ubuntu:~/www/html/js to qa@desktop2:~/home/qa/html/js scp is pretty powerful, so I suggesting reading the man page for it at

man scp

Solution 2

Edit: You'll have trouble copying files via telnet my friend. Why do you insist on using a terminal?

Meaning, you’re running Windows, so presumably have access to a graphical environment. So would using windows file sharing / a web browser / ftp client / ssh client / etc be ruled out because they're graphical? And if so, why?

Do you have root access on the Ubuntu machine? I would suggest you install an ssh server:

sudo apt-get install openssh-server

Then grab a windows SSH/SCP client, eg. WinSCP, and use it to log in to the server and copy your files.

Or if you really really want to do it via the terminal for some reason, grab Cygwin and install opens, then use the 'scp' command mentioned below.

You need to be a little more specific about your situation.

  • what OS is the client running?
  • what OS is the server running?
  • what services is the server running, if you know (FTP, HTTP, NFS, SMB, SSH, etc)

For example, if you have SSH access to the server, something like this would work:

scp [email protected]:/remote/path/file.txt /local/path/

If you have HTTP access to the file (http://server.mydomain.com/path/file.txt) then as the poster above suggested, wget:

wget http://server.mydomain.com/path/file.txt

The answer depends heavily on your situation.

Solution 3

If you're using Windows for this, and you really can't use HTTP in any way to get the file, you can resort to old-school file-transfer over 7-bit ASCII protocols. I'm talking about Z-Modem. It last saw major use over dial-up internet, specifically in the BBS world, with a side-line in unix-to-unix transfers when FTP wasn't available (generally over rsh, but I'm digressing).

Anyway, to get that directory tree from Windows, without using FTP or HTTP, just terminal.

  1. Telnet to server using HyperTerm.
  2. Tar/Zip up the directories you're interested in.
  3. From the command line,
    sz filename.tar.gz  
  4. From Hyperterm, select Transfer -> Receive File.
  5. Specify your save path, and "Zmodem" as the receiving protocol.

It won't transfer as fast as FTP or HTTP would, but it'll get you files.

Solution 4

If ssh/scp is not available, try netcat.

http://nakkaya.com/2009/04/15/using-netcat-for-file-transfers/

Netcat is basically a simple file dump to a network port. It's useful for transfer to a barebone host when ssh isn't available, or transferring very large files over LAN/internet where SSH encryption overhead becomes a bottleneck.

That said, scp is still the standard way to do transfer files from remote hosts. And if you're trying to transfer a whole directory, it's best to using rsync over ssh:

rsync -avz -e ssh qa@ubuntu:~/www/html/js  ~/home/qa/html

Scp traverses the directory as it's transferred, it can be very slow with large folders. Rsync traverses through the entire directory and applies gzip compression before transfer begins. If a local copy exists, rsync with compare the two and transfer only the delta: the changed portion of the files.

And an added correction for previous scp suggestion: scp a whole directory reqiures the -r option:

scp -r qa@ubuntu:~/www/html/js  ~/home/qa/html
Share:
11,356

Related videos on Youtube

klox
Author by

klox

Updated on September 17, 2022

Comments

  • klox
    klox over 1 year

    I have one folder to copy that consists of PHP and similar files for creating a web site.

    How do I copy one folder from the server (Linux Ubuntu) to the client PC (Linux Ubuntu) using terminal? Could I use ftp? For the terminal connection I'm using Telnet.

    The folder location on the server:

    qa@ubuntu:~/www/html/js 
    

    And I want to copy it to the client at:

    qa@desktop2:~/home/qa/html
    
  • klox
    klox almost 14 years
    look at my edited question..
  • klox
    klox almost 14 years
    the folder location at server: qa@ubuntu:~/www/html/js and i want to copy at client: qa@desktop2:~/home/qa/html
  • user1686
    user1686 almost 14 years
    The correct syntax is user@host:path, not user@host/~/path. If I understood it correctly, your example should be scp qa@ubuntu:www/html/js qa@desktop2:home/qa/html (although it's unclear whether @klox wanted ~/home/qa/html or ~/html).
  • Aatch
    Aatch almost 14 years
    Oops, sorry, my bad. Thanks for the correction.