I am logged onto a windows machine. I am using Putty to login to an Ubuntu machine on the same network. Now I'm trying to move a .c file from the Ubuntu machine, to the Windows machine, edit it there, then move it back to the Ubuntu machine, compile it, and run it.

I'm still stuck at obtaining the C file.

I'm running this command...

sudo scp odroid:/home/odroid/test/test.c C\Users\MyUser\Downloads 

Instead of moving the file to my Windows machine...somehow I'm creating an un-extended file in the home directory of my Ubuntu machine.

What am I doing wrong?

  • What is an "un-extended file"? Also, which machine is odroid and which machine is the one where you're running the sudo scp command? – Celada Apr 30 '15 at 1:17
  • I assume it's an "un-extended file" by this I mean that I'm creating something called CUsersMyUserDownloads in the home directory. It's not a directory because I can't answer it, and it has no extensions, so it's just an empty file name. Odroid is the Ubuntu machine. I'm logged into it via Putty from the Windows machine. I.E. I'm running Putty and sitting at the Windows machine. I'm logged into the Ubuntu machine...I.E. I'm using the Ubuntu Terminal. – Allenph Apr 30 '15 at 1:24
  • 1
    Unless you have installed an SSH server on Windows, you won't be able to use scp on the remote machine to copy to the local (Windows) machine. Either use pscp.exe from the Windows command line (it is part of the "full" PuTTY install), or (much easier) install and use WinSCP on the Windows machine. – steeldriver Apr 30 '15 at 1:28

In similar cases, I've used WinSCP. It's a Windows SCP client that allows you to browse the Linux file system graphically and scp files back and forth between the 2 machines.

Available here : http://winscp.net/eng/index.php

  • I second WinSCP. I use it often from Windows to access files on Unix/Linux over ssh/sftp. It automates what you are trying to do. It lets you "edit" a file, which behind the scenes, downloads it to a temporary file on your Windows machine, opens it in Notepad (or whatever editor you want), and then when you Save (or Save/Exit), it transfers the file back to the Unix/Linux host. – Joshua Huber Apr 30 '15 at 3:14

You're doing this the very hardest way, but here you go:

  1. Get the wonderful pscp program. I'm not a Windows person at all so all I can tell you is put pscp.exe in your %path%.
  2. On the Windows machine, change directory to C:\Users\MyUser\Downloads
  3. On the Windows machine: pscp test.c odroid:test/ You'll probably have to type in your Ubuntu password.
  4. On the Ubuntu machine, compile and test.

You have to "pull" the file from your Linux machine, because Microsoft artificially makes computers into "servers" and "clients" (presumably to create false high price points for corporate buyers) and doesn't see fit to put a SSH server on anything. For that matter, you may need to start sshd on your Ubuntu box.

Honestly, you'd be better off doing text editing on the Ubuntu machine. First, there's an amazing range of editors of various types available, from NotePad imitators to full-blown IDEs. Second, you're going to have problems with end-of-line bytes moving the file back-and-forth between Windows and Linux. At some point, the compiler will refuse to compile something, or your Windows editor won't recognize a single newline character as end-of-line.

  • Well...the Odroid is an off-brand Raspberry Pi. It's not hooked up to a monitor. I'm developing a C program to run a laser engraver I made that's attached to the GPIOs on the Odroid. Therefore, I have to use my laptop to write the code, move the code, execute the code, etc. – Allenph Apr 30 '15 at 1:30
  • @Allenph - those details are materially relevant to getting a good answer. I'm not at all certain that whatever distro you're running on your "odroid" will have an SSH server. It might have dropbear or it might have something else. – Bruce Ediger Apr 30 '15 at 1:51
  • The Odroid is running a custom Ubuntu 14.04 image with a built in SSH server which is on by default. Connecting to the Odroid is not a problem. I can view files, execute C programs, etc. The problem is moving the file. The idea is to create a program in Windows with a GUI which will contain a file selector which is used to select a file (Gcode) on the windows machine, rename the file to the file-name accepted by my C program on the Odroid that runs the engraver, and upload it. Then there will be a print button, which tells the Odroid to execute the C program which runs the engraver. – Allenph Apr 30 '15 at 2:04
  • @Allenph - that's more informative than your question above. WinSCP (winscp.net/eng/index.php) might be your answer. Otherwise, good luck on the Win32 project. – Bruce Ediger Apr 30 '15 at 2:24

I've had to deal with this a lot, and I used to teach a few classes where students needed to work from Windows machines. I'll describe two methods, and you decide what you like best. Also, warning: I am not a Windows user, I just provide support for them when they need to work with Unix :).

  1. Use WinSCP (http://winscp.net/eng/download.php)

    WinSCP is just a GUI which works similarly to PuTTY, but you can browse files on the remote server. I've found it fairly acceptable, and it's a GUI so you can just drag and drop files/folders between your local Windows machine, and the remote Ubuntu Linux machine.

  2. Use Sublime Text 3 (https://www.sublimetext.com/3) along with the Sublime SFTP plugin (sorry, you'll have to search for this)

    (Ok, I'm basically endorsing this one text editor, but ever since a friend of mine showed it to me, I've found it to be my preferred editor in most circumstances. Other editors might let you do something like this; please feel free to check them out. I'm sure everyone has their favorite.)

    ST is paid software available on a trial basis, and will keep asking you to buy it every few times you save. You can safely ignore this forever and it doesn't cost you any functionality to use it for free, but just be aware of this (and if you can support the developers...). The SFTP plugin will also nag you to buy it.

    This is how I use ST3 and the SFTP plugin (I assume you've already installed both).

If you're going to be working with all files in a remote folder

  • Open ST3 and select File -> "Open Folder"
  • Create a new folder, if you wish. This folder will hold all the files you need to work with. Otherwise, just select a folder.
  • In the left sidebar, right click on the folder name or icon. Choose SFTP/FTP -> "Map to Remote".
  • ST3 will open a config file for setting up your connection. Fill in the important values (host, user, remote_path). remote_path should be the directory that your local directory will be "mirroring" in a sense. You can also set upload_on_save to true if you want your files to be copied automatically to the remote server every time you save.
  • Save the file and right-click on the folder name again. This time, pick SFTP/FTP -> "Sync Remote -> Local...". Warning: if the folder you picked has files in it, this will overwrite them.
  • Select "Yes" when it asks to perform the operations shown in the console.
  • Now your files will show up on the side bar. You can open them, edit them, and save them, all on you local machine. If you did not set the upload_on_save option, you can right click on the file name, or anywhere inside the file and pick SFTP/FTP -> "Sync Local -> Remote..." to copy it back.

If you're going to be working with just one file

It may be easier for you to just edit the file in Sublime Text, via the SFTP plugin. This gives you the feeling of working with it locally, but really, only a cached version of it exists on your local machine. The developer of the SFTP plugin calls this the "Server" workflow (you can read about it on their page). Basically:

  • Open ST3, File -> SFTP/FTP -> "Set up server..."
  • Fill in the config file, similarly to how I described above, and save it with a name (maybe the name of the server is a good idea).
  • File -> SFTP/FTP -> "Browse remote..."
  • Use the rather clunky interface to browse for your file, select it, then select "Edit"
  • Edit your file as you wish. Saving uploads it automatically.

I found that ST3 works well enough for my needs. Hopefully this helps you at least somewhat. If you're not looking for another editor, hopefully WinSCP helps you do what you need to do.


ensure that you have the pscp first, use the git Bash instead of windows power shell, scp odroid:/home/odroid/test/test.c C\Users\MyUser\Downloads

  • this hardly add anything to @Bruce Ediger answer. – Archemar Jun 21 '17 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.