Copy to linux from windows

copy file/folder using scp command

How can I copy a file/folder from windows to linux (putty), probably using scp command? I used scp user@hostname(windows):c:\folder\filname user@hostname(Linux):/folder/filename(destination), but unfotunately I got an error. Basically, I am trying to copy from windows to Linux. Hope it works whether I am on windows or Linux.

3 Answers 3

I don’t think this can work in this form, with the backslash \ separators:

scp user@hotname:c:\folder\filname user@hostname:\folder\filename(destination) 

First of all, the path separator in Linux is / instead of \ , so this would be better:

scp user@hotname:c:\folder\filname user@hostname:/folder/filename 

Secondly, your command looks like as if you’re running this command on a third PC, on machineC to copy files from machineA to machineB. If this is not the case and you are in fact on machineA copying files to machineB, then this would be better:

scp c:\folder\filname user@hostname:/folder/filename 

If you don’t have the scp command in Windows, here are a few options:

  • Install Git. Even if you don’t use Git, this installer includes an excellent terminal and common *nix commands, and scp too
  • Download PuTTY. You can use pscp.exe instead of scp , the above syntax will work.
  • Install WinSCP. It has scripting features, but if you want to use the command line the previous two options are easier.

If I do from windows I get ‘scp’ is not recognized as an internal or external command,operable program or batch file. If I do from Linux to my windows machine then I get «ssh: connect to host port 22: Connection refused lost connection» I think I have to use Winscp.

In *nix systems, this should work:

# to copy file.ext from remote server to current working directory # note the dot (.) at the end, which means current directory $ scp user@remote.server.com:~/desired/folder/file.ext . # to copy all files in a folder from remote server # to current directory # note the dot (.) at the end, which means current directory $ scp -r user@remote.server.com:~/desired/folder/* . # copy a folder and all its contents as it is from remote server # to current directory # note the dot (.) at the end, which means current directory $ scp -r user@remote.server.com:~/dersired/folder . 

More information can also be found in this article: scp command syntax

Читайте также:  Samsung dex for linux

Источник

How to Use SCP from Windows to Linux

In the Linux Operating system, we use the SCP command to copy the files or directories from our local machine to a remote server or from a remote server to our local machine. It can also be used to transfer the files between two remote servers using your local machine. It is a very useful command line utility and comes in handy when we need to transfer our files securely. SCP is the short form of Secure Copy Protocol. This command uses SSH keys or Secure Shell keys for the secure transfer of data.

SSH keys are a couple of private and public keys that are used to establish an encrypted and encoded connection between a remote server and a client server. SCP is famous for its ease of use, secured transfer, and preinstalled availability. SCP Command commands a set of options whose purpose is to keep track of its functionality and control its behavior. The following are a few options that are used more popularly:

SCP – P port: Allocates the port that is required for a connection to a remote server.

SCP -p: Keeps record of modification dates, access dates, creation dates, etc.

SCP -q: Used to disable the non-error messages and progress bar.

SCP -r: It removes and copies whole directories.

SCP -s: A program that specifies the name of the program that is used to encrypt the connection. The program must be the one that can understand the SSH options.

SCP -v: Enables the debugging options and displays the process step by step. It becomes helpful when we are facing authentication or connection problems.

When we are copying or moving the data from one server to another. The whole connection is secured by making sure that all the files and passwords are encrypted so that any stalker that comes in traffic does not get his hands on anything sensitive.

Читайте также:  Var log messages linux logging

Syntax:

The following command is used to move the files from a local system to a remote one:

    • OPTION – Scp options such as cipher, ssh configuration, ssh port, limit, recursive copy…etc.
    • [user@]SRC_HOST:]file1 – Source file
    • [user@]DEST_HOST:]file2 – Destination file

    The following command is used to transfer the directories of files from the remote to the local system.

    Transfer Files Using SCP in Linux from Local to Remote System

    The SCP allows us to transfer the files from local to remote system or from remote to the local system. We can perform both tasks using SCP utility. To get a better understanding of the use of SCP, we perform the file transfers from remote to local system and from local to remote system.

    Let’s suppose we have a file named “myfile” in our local system and we want to transfer it to the remote system. To do so, we must have an SSH connection between the local and the remote system. To check the installation of the SSH, we first open the command prompt in our local system. Then, we write a command to check whether we have an access to the SCP or not.

    After running the previous command, we get the output that is shown in the following snippet which shows that the usage here is SCP, followed by flags and the source in a target computer.

    Now, we create a new file using a notepad which we named “myfile” where we write the simple “this is SP file transfer” text as shown in the following figure:

    Now, we transfer the file from our local system to the remote system. For that, we must have the IP and the path of the remote system where we want to store the file. But before that, we must have the SSH installed in our remote system. To check for the SSH installation, we run the following command:

    After running the command, we receive this output which shows that we do not have an installed SSH in our system:

    For the installation of SSH, let us first update the system to the latest version. To update the version, we run the following command:

    After running the previous command, our system is upgraded. As shown in the following snippet, we successfully updated the system:

    Now, we install SSH in our remote system. For that, we run the command that is displayed in the following after pressing “enter”, and our installation starts:

    When we run the command for the installation of SSH, it will ask for permission to continue the installation or not by entering the “y” letter to grant the permission to install the SSH services.

    Now, we successfully install the SSH server. Our next step is to allow the port 22/tcp for SSH. To do so, we write the following command in the terminal:

    We get this message on running the previous command.

    Let us check the status of the SSH again whether it is working or not. To check this, we write the previously-mentioned command that is used to check the status of the SSH. After that, as in the following snippet, we can see that our SSH is now active.

    We now attempt to copy the file from the local system to the remote system. For this, we open the command prompt in the local system.

    It allows us to transfer the “myfile.txt” file to the remote system named “linux” along with the “10.0.2.255” IP address and also the location where it is to be stored. As we can see in the following, we successfully transferred the file from the local to the remote user.

    Conclusion

    In this article, we introduced you to the SCP commands that are used to transfer files from one system to another. We also performed an example to explain how we can perform this task without any problems.

    About the author

    Omar Farooq

    Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.

    Источник

Оцените статью
Adblock
detector