Ssh file transfer windows to linux

SCP copy windows local file to linux remote folder

Or you can use WinSCP, you’ll probably find that simpler.

The best way to copy files from Windows to Linux using the command line is through pscp. It is very easy and secure. For pscp to work on your windows machine, you need it add its executable to your systems path. Once it is done, you can use the following format to copy the file.

pscp -pw password D:\test.txt user@192.168.33.10:/etc/var/test/test.txt 

You can refer the following blog post for more information on pscp setup.

To improve your answer, I suggest you include some relevant quotes / summary in your answer . (leaving the hyperlink in it is fie, eg for those who want more background info, etc)

Assuming you are on Windows, best way is to download and install cygwin. Get the path to the binary folder and add it to the system path. You can now run Linux commands on your command line.

Open the command prompt and go to the directory where your file is that you want to copy. Run the following command;

  • scp — secure copy command
  • file.txt — file you want to copy
  • root — username used to log onto CentOS machine
  • 1.1.1.1 — IP address of CentOS machine. Needless to say your Windows machine and the CentOS machine have to be able to communicate with one another
  • :/opt — This is the directory with which you save the file to, I generally save everything to the /opt directory
  • Don’t forget the @ between the username and IP Address and the : between the IP Address and directory you are saving the file to

If you need a key to login into the server, enter the following;

scp key.pem file.txt root@1.1.1.1:/opt 

For handiness sake I just copy the file I want to copy across to the key file directory, that way you know everything will run smoothly

Читайте также:  Linux mint dual monitors

Источник

Копирование файлов через SSH

В статье мы расскажем, как копировать файлы в Windows и Linux-системах, и покажем основные команды, с помощью которых происходит передача файлов по SSH.

Для копирования файлов по SSH в Linux-системах и Windows используют разные инструменты:

  • scp (Secure CoPy) — утилита для безопасного копирования данных между Linux-системами по протоколу SSH. Она входит в состав OpenSSH, поэтому для работы с утилитой не нужно устанавливать дополнительное ПО;
  • pscp.exe — утилита для загрузки файлов по SSH в ОС Windows. Она обладает теми же возможностями, что и scp. Утилита входит в состав программы Putty — SSH-клиента для Windows. Скачать программу можно по ссылке.

Если файл, который вы хотите скопировать, уже существует на целевом хосте, при копировании он будет перезаписан.

Копирование файлов по SSH на Linux

Для Linux копирование файлов по SSH происходит с использованием команды scp. С её помощью можно копировать файлы:

  • с локального компьютера на удалённый сервер,
  • с удалённого сервера на локальный компьютер,
  • с одного удалённого сервера на другой.
scp [опция] [источник] [получатель]

Как скопировать файл по SSH с локальной машины на удалённый сервер

Как загрузить файл на сервер по SSH? Для этого используйте команду вида:

scp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]
scp /home/test.txt root@123.123.123.123:/directory

Файл test.txt будет скопирован на хост 123.123.123.123 в директорию «/directory».

Как скопировать файлы с удалённого сервера на локальный компьютер

При подключённом SSH скачать файл на локальный компьютер с удалённого сервера можно с помощью команды:

scp [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу] [путь к файлу]
scp root@123.123.123.123:/home/test.txt /directory

Файл test.txt будет загружен с сервера 123.123.123.123 на локальный компьютер в папку «/directory».

Как скопировать файл по SSH с одного удалённого сервера на другой

Подключитесь по SSH к серверу, на котором расположен файл. Затем выполните команду:

scp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]
scp /home/test.txt root@123.123.123.123:/directory

Файл test.txt будет скопирован на хост 123.123.123.123 в директорию «/directory».

Как скачать папку со всеми файлами и подпапками

Если вы хотите скачать папку со всеми файлами и подпапками, используйте ключ -r:

scp -r [источник] [получатель]

Как подключиться к серверу по нестандартному порту

Бывает, что для подключения по SSH нужно указать нестандартный порт. Без указания порта команда подключается к серверу по стандартному 22 порту. Чтобы указать нестандартный порт, введите команду с ключом -P:

scp -P [источник] [получатель]
scp -P 12345 /home/test.txt root@123.123.123.123:/directory

Эта команда подключается по порту 12345 к серверу 123.123.123.123 и копирует на него файл «test.txt» с локального компьютера в директорию «/directory».

Читайте также:  Arch linux installation wifi

Как передать и скачать файлы по SSH на Windows

Скопировать файл по SSH на сервер можно командой:

pscp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]

Скачать файл по SSH с сервера командой:

pscp [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу] [путь к файлу]

Увидеть список папок и файлов на сервере можно через pscp.exe. Для этого введите:

pscp -ls [имя пользователя]@[имя сервера/ip-адрес]:[путь]

Если в пути или в названии файла есть пробелы, используйте кавычки:

pscp “C:\files or docs\file name” root@123.123.123.123:/home

Источник

Copying a local file from Windows to a remote server using scp [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I try to transfer a folder of files from my local computer to a server via ssh and scp . After getting sudo privileges, I’m using the command as follows:

scp -r C:/desktop/myfolder/deployments/ user@host:/path/to/whereyouwant/thefile 

None of the non-GUI solutions work for me. I get the error, fork: No such file or directory. I can ssh the destination and I can dir to the source.

7 Answers 7

If your drive letter is C, you should be able to use

scp -r \desktop\myfolder\deployments\ user@host:/path/to/whereyouwant/thefile

without drive letter and backslashes instead of forward slashes.

You are using putty, so you can use pscp. It is better adapted to Windows.

scp -r root@31.222.168.64:/var/www/vhosts/mywork \test — I added this code this is create a test folder in my server no in my local computer scp -r root@31.222.168.64:/var/www/vhosts/mywork D:\test —gives error «ssh: Could not resolve hostname D: Name or service not known lost connection»

@pTi which scp are you using? If you are using Cygwin’s scp , you can use the path as /cygdrive/d/test . To omit using /cygdrive you can run mount —change-cygdrive-prefix / so that the path would be /d/test instead.

Читайте также:  Как очистить директории linux

Not sure if it’s specific to tunneling or to the version of scp in Windows 10, but I had to use the syntax (after lots of trials and errors): scp -P -r ./localdir user@host:»D:\remotedir»

Drive letters can be used in the target like

scp some_file user@host:/c/temp 

where c is the drive letter. It’s treated like a directory.

Maybe this works on the source, too.

Thanks for this simple and working answer, not trying to make me use another software or whatever ! I was searching the web to find just that, nobody answers the question directly.

In my case, user@host:/ is the root for my C:\ directory. So if I write user@host:/temp/ , it is equivalent to C:\temp\ . I only have access to my C Drive, not others.

@imans77, that may work, but if your drive letter is e: it won’t 😉 That was the case for me and how I discovered this.

On windows you can use a graphic interface of scp using winSCP. A nice free software that implements SFTP protocol.

I see this post is very old, but in my search for an answer to this very question, I was unable to unearth a solution from the vast internet super highway. I, therefore, hope I can contribute and help someone as they too find themselves stumbling for an answer. This simple, natural question does not seem to be documented anywhere.

On Windows 10 Pro connecting to Windows 10 Pro, both running OpenSSH (Windows version 7.7p1, LibreSSL 2.6.5), I was able to find a solution by trial and error. Though surprisingly simple, it took a while. I found the required syntax to be

BY EXAMPLE INSTEAD OF MORE OBSCURE AND INCOMPLETE TEMPLATES:

Transferring securely from a remote system to your local system:

scp user@remotehost:\D\mySrcCode\ProjectFooBar\somefile.cpp C:\myRepo\ProjectFooBar 

or going the other way around:

scp C:\myRepo\ProjectFooBar\somefile.cpp user@remotehost:\D\mySrcCode\ProjectFooBar 

I also found that if spaces are in the path, the quotations should begin following the remote host name:

scp user@remotehost:"\D\My Long Folder Name\somefile.cpp" C:\myRepo\SimplerNamerBro 

Also, for your particular case, I echo what Cornel says:

On Windows, use backslash, at least at conventional command console.

Kind Regards. RocketCityElectromagnetics

Источник

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