Putty copy from linux to windows

I am running a putty client on a Windows machine to connect successfully to a Linux box. Now I want to be able to copy a file from the Linux machine under the path /home/ubuntu/myfile to C:/Users/A...

I am running a putty client on a Windows machine to connect successfully to a Linux box. Now I want to be able to copy a file from the Linux machine under the path /home/ubuntu/myfile to C:/Users/Anshul/Desktop on my local computer. The user at the Windows machine is anshul. I am giving the following command on putty but it is not working:

scp /home/ubuntu/myfile ip_address_of_windows_machine:C:/Users/Anshul/Desktop 

I think the path for the Windows machine is wrong. Please help as I have banged my head on a large number of forums but none seem to give correct path for Windows server. Don’t suggest alternate options like WinScp

Guy Avraham's user avatar

Guy Avraham

3,3623 gold badges40 silver badges49 bronze badges

asked Apr 19, 2012 at 19:56

user1344963's user avatar

5

This one worked for me.

scp /home/ubuntu/myfile username@IP_of_windows_machine:/C:/Users/Anshul/Desktop 

answered Mar 12, 2018 at 6:04

emoblazz's user avatar

emoblazzemoblazz

1,3111 gold badge6 silver badges3 bronze badges

6

Download pscp from Putty download page, then use it from Windows Command Line CMD as follows:

pscp username_linux_machine@ip_of_linux_machine:/home/ubuntu/myfile.ext C:UsersNameDownloads

Copying starts once you enter the password for the Linux machine.

ifnotak's user avatar

ifnotak

3,8673 gold badges21 silver badges35 bronze badges

answered Jun 8, 2016 at 20:49

Hesham Eraqi's user avatar

Hesham EraqiHesham Eraqi

2,4254 gold badges22 silver badges45 bronze badges

3

Try this, it really works.

$ scp username@from_host_ip:/home/ubuntu/myfile /cygdrive/c/Users/Anshul/Desktop

And for copying all files

$ scp -r username@from_host_ip:/home/ubuntu/ *. * /cygdrive/c/Users/Anshul/Desktop

fluffyBatman's user avatar

fluffyBatman

6,3443 gold badges22 silver badges24 bronze badges

answered Jun 10, 2014 at 11:57

Chris Alexander sebastian's user avatar

8

Access from Windows by Git Bash console (also works for CMD and PowerShell):

scp user@ip:/dir1/dir2/file "D:dir1dir2"

Wenfang Du's user avatar

Wenfang Du

7,3807 gold badges49 silver badges79 bronze badges

answered Jan 4, 2019 at 13:18

byteprom's user avatar

byteprombyteprom

4514 silver badges4 bronze badges

5

You could use something like the following

scp -r linux_username@linux_address:path/to/file path/to/local/directory

This will copy file to the specified local directory on the system you are currently working on.

The -r flag tells scp to recursively copy if the remote file is a directory.

answered Feb 16, 2015 at 23:58

Atif's user avatar

AtifAtif

3251 gold badge4 silver badges16 bronze badges

Windows doesn’t support SSH/SCP/SFTP natively. Are you running an SSH server application on that Windows server? If so, one of the configuration options is probably where the root is, and you would specify paths relative to that root. In any case, check the documentation for the SSH server application you are running in Windows.

Alternatively, use smbclient to push the file to a Windows share.

George's user avatar

George

6,5193 gold badges42 silver badges56 bronze badges

answered Apr 19, 2012 at 19:59

theglauber's user avatar

theglaubertheglauber

27.9k7 gold badges29 silver badges46 bronze badges

5

For all, who has installed GiT completly with «Git Bash»: You can just write:

scp login@ip_addres:/location/to/folders/file.tar .

(with space and DOT at the end to copy to current location). Than just add certificate (y), write password and that’s all.

answered Oct 3, 2017 at 12:31

Krzysztof Walczewski's user avatar

1

Your code isn’t working because c:/ or d:/ is totally wrong for linux just use /mnt/c or/mnt/c

From your local windows10-ubuntu bash use this command:

for download:
(from your remote server folder to d:/ubuntu) :

scp username@ipaddress:/folder/file.txt /mnt/d/ubuntu

Then type your remote server password if there is need.

for upload:
(from d:/ubuntu to remote server ) :

scp /mnt/d/ubuntu/file.txt username@ipaddress:/folder/file.txt 

Then type your remote server password if there is need.
note: I tested and it worked.

answered Feb 19, 2019 at 12:09

Baris Vvolf's user avatar

I had to use pscp like above Hesham’s post once I downloaded and installed putty. I did it to Windows from Linux on Windows so I entered the following:

c:ssl>pscp username@linuxserver:keenan/ssl/* .

This will copy everything in the keenan/ssl folder to the local folder (.) you performed this command from (c:ssl). The keenan/ssl will specify the home folder of the username user, for example the full path would be /home/username/keenan/ssl. You can specify a different folder using a forward slash (/), such as

c:ssl>pscp username@linuxserver:/home/username/keenan/ssl/* .

So you can specify any folder at the root of Linux using :/.

halfer's user avatar

halfer

19.7k17 gold badges95 silver badges183 bronze badges

answered Dec 14, 2018 at 12:47

Keenan Stewart's user avatar

To send a file from windows to linux system

scp path-to-file user@ipaddress:/path-to-destination

Example:

scp C:/Users/adarsh/Desktop/Document.txt root@127.0.0.1:/tmp

keep in mind that there need to use forward slash(/) inplace of backward slash() in for the file in windows path else it will show an error

C:UsersadarshDesktopDocument.txt: No such file or directory

.
After executing scp command you will ask for password of root user in linux machine.
There you GO…

To send a file from linux to windows system

scp -r user@ipaddress:/path-to-file path-to-destination

Example:

scp -r root@127.0.0.1:/tmp/Document.txt C:/Users/adarsh/Desktop/

and provide your linux password.
only one you have to add in this command is -r.
Thanks.

answered Mar 15, 2019 at 6:00

ADARSH K's user avatar

ADARSH KADARSH K

5967 silver badges20 bronze badges

Here is the solution to copy files from Linux to Windows using SCP without password by ssh:

  1. Install sshpass in Linux machine to skip password prompt

  2. Script

    sshpass -p 'xxxxxxx' scp /home/user1/*.* testuser@x.x.x.x:/d/test/

Details:

sshpass -p 'password' scp /source_path/*.* windowsusername@windowsMachine_ip:/destination_drive/subfolder/

serenesat's user avatar

serenesat

4,59110 gold badges35 silver badges53 bronze badges

answered Aug 28, 2015 at 12:47

Ramarajan Jothi's user avatar

As @Hesham Eraqi suggested, it worked for me in this way (transfering from Ubuntu to Windows (I tried to add a comment in that answer but because of reputation, I couldn’t)):

pscp -v -r -P 53670 user@xxx.xxx.xxx.xxx:/data/genetic_map/sample/P2_283/* \Desktop-mojbd3ndcc_01-1940_data

where:

-v: show verbose messages.
-r: copy directories recursively.
-P: connect to specified port.
53670: the port number to connect the Ubuntu server.
\Desktop-mojbd3ndgenetic_map_data: I needed to transfer to an external HDD, thus I had to give permissions of sharing to this device.

answered Jun 27, 2019 at 3:37

giannkas's user avatar

giannkasgiannkas

1683 silver badges14 bronze badges

Open bash window. Preferably git bash.
write

scp username@remote_ip:/directory_of_file/filename ‘windows_location_you_want_to_store_the_file’

Example:

Suppose your username is jewel

your IP is 176.35.96.32

your remote file location is /usr/local/forme

your filename is logs.zip

and you want to store in your windows PC’s D drive forme folder
then the command will be

scp jewel@176.35.96.32:/usr/local/forme/logs.zip ‘D:/forme’

**Keep the local file directory inside single quote.

answered Apr 7, 2019 at 6:02

Zenith's user avatar

ZenithZenith

9371 gold badge8 silver badges21 bronze badges

I know this is old but I was struggling with the same. I haven’t found a way to change directories, but if you just want to work with the C drive, scp defaults to C. To scp from Ubuntu to Windows, I ended up having to use (notice the double back-slashes):

scp /local/file/path user@111.11.11.111:Users\Anshul\Desktop

Hope this helps someone.

Racil Hilan's user avatar

Racil Hilan

24.2k12 gold badges49 silver badges52 bronze badges

answered Jul 29, 2016 at 0:35

Acmag's user avatar

AcmagAcmag

12 bronze badges

2

Try this:

scp /home/ubuntu/myfile C:usersAnshulDesktop

Pang's user avatar

Pang

9,344146 gold badges85 silver badges121 bronze badges

answered Jan 12, 2013 at 2:50

Corey Burnett's user avatar

Corey BurnettCorey Burnett

7,2629 gold badges54 silver badges92 bronze badges

1

If you want to copy paste files from Unix to Windows and Windows to Unix just use filezilla with port 22.

answered Sep 4, 2012 at 7:38

user1645422's user avatar

предыдущая глава | содержание | следующая глава

  • 5.1 Starting PSCP
  • 5.2 PSCP Usage
    • 5.2.1 The basics
    • 5.2.2 Options
    • 5.2.3 Return value
    • 5.2.4 Using public key authentication with PSCP

PSCP, the PuTTY Secure Copy client, is a tool for transferring files securely between computers using an SSH connection.

If you have an SSH-2 server, you might prefer PSFTP (see chapter 6) for interactive use. PSFTP does not in general work with SSH-1 servers, however.

5.1 Starting PSCP

PSCP is a command line application. This means that you cannot just double-click on its icon to run it and instead you have to bring up a console window. With Windows 95, 98, and ME, this is called an «MS-DOS Prompt» and with Windows NT, 2000, and XP, it is called a «Command Prompt». It should be available from the Programs section of your Start Menu.

To start PSCP it will need either to be on your PATH or in your current directory. To add the directory containing PSCP to your PATH environment variable, type into the console window:

set PATH=C:pathtoputtydirectory;%PATH%

This will only work for the lifetime of that particular console window. To set your PATH more permanently on Windows NT, 2000, and XP, use the Environment tab of the System Control Panel. On Windows 95, 98, and ME, you will need to edit your AUTOEXEC.BAT to include a set command like the one above.

5.2 PSCP Usage

Once you’ve got a console window to type into, you can just type pscp on its own to bring up a usage message. This tells you the version of PSCP you’re using, and gives you a brief summary of how to use PSCP:

Z:owendadmin>pscp
PuTTY Secure Copy client
Release 0.73
Usage: pscp [options] [user@]host:source target
       pscp [options] source [source...] [user@]host:target
       pscp [options] -ls [user@]host:filespec
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -p        preserve file attributes
  -q        quiet, don't show statistics
  -r        copy directories recursively
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -P port   connect to specified port
  -l user   connect with specified username
  -pw passw login with specified password
  -1 -2     force use of particular SSH protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for user authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -hostkey aa:bb:cc:...
            manually specify a host key (may be repeated)
  -batch    disable all interactive prompts
  -no-sanitise-stderr  don't strip control chars from standard error
  -proxycmd command
            use 'command' as local proxy
  -unsafe   allow server-side wildcards (DANGEROUS)
  -sftp     force use of SFTP protocol
  -scp      force use of SCP protocol
  -sshlog file
  -sshrawlog file
            log protocol details to a file

(PSCP’s interface is much like the Unix scp command, if you’re familiar with that.)

5.2.1 The basics

To receive (a) file(s) from a remote server:

pscp [options] [user@]host:source target

So to copy the file /etc/hosts from the server example.com as user fred to the file c:tempexample-hosts.txt, you would type:

pscp fred@example.com:/etc/hosts c:tempexample-hosts.txt

To send (a) file(s) to a remote server:

pscp [options] source [source...] [user@]host:target

So to copy the local file c:documentsfoo.txt to the server example.com as user fred to the file /tmp/foo you would type:

pscp c:documentsfoo.txt fred@example.com:/tmp/foo

You can use wildcards to transfer multiple files in either direction, like this:

pscp c:documents*.doc fred@example.com:docfiles
pscp fred@example.com:source/*.c c:source

However, in the second case (using a wildcard for multiple remote files) you may see a warning saying something like «warning: remote host tried to write to a file called «terminal.c» when we requested a file called «*.c». If this is a wildcard, consider upgrading to SSH-2 or using the «-unsafe» option. Renaming of this file has been disallowed».

This is due to a fundamental insecurity in the old-style SCP protocol: the client sends the wildcard string (*.c) to the server, and the server sends back a sequence of file names that match the wildcard pattern. However, there is nothing to stop the server sending back a different pattern and writing over one of your other files: if you request *.c, the server might send back the file name AUTOEXEC.BAT and install a virus for you. Since the wildcard matching rules are decided by the server, the client cannot reliably verify that the filenames sent back match the pattern.

PSCP will attempt to use the newer SFTP protocol (part of SSH-2) where possible, which does not suffer from this security flaw. If you are talking to an SSH-2 server which supports SFTP, you will never see this warning. (You can force use of the SFTP protocol, if available, with -sftp — see section 5.2.2.6.)

If you really need to use a server-side wildcard with an SSH-1 server, you can use the -unsafe command line option with PSCP:

pscp -unsafe fred@example.com:source/*.c c:source

This will suppress the warning message and the file transfer will happen. However, you should be aware that by using this option you are giving the server the ability to write to any file in the target directory, so you should only use this option if you trust the server administrator not to be malicious (and not to let the server machine be cracked by malicious people). Alternatively, do any such download in a newly created empty directory. (Even in «unsafe» mode, PSCP will still protect you against the server trying to get out of that directory using pathnames including «..».)

5.2.1.1 user

The login name on the remote server. If this is omitted, and host is a PuTTY saved session, PSCP will use any username specified by that saved session. Otherwise, PSCP will attempt to use the local Windows username.

5.2.1.2 host

The name of the remote server, or the name of an existing PuTTY saved session. In the latter case, the session’s settings for hostname, port number, cipher type and username will be used.

5.2.1.3 source

One or more source files. Wildcards are allowed. The syntax of wildcards depends on the system to which they apply, so if you are copying from a Windows system to a UNIX system, you should use Windows wildcard syntax (e.g. *.*), but if you are copying from a UNIX system to a Windows system, you would use the wildcard syntax allowed by your UNIX shell (e.g. *).

If the source is a remote server and you do not specify a full pathname (in UNIX, a pathname beginning with a / (slash) character), what you specify as a source will be interpreted relative to your home directory on the remote server.

5.2.1.4 target

The filename or directory to put the file(s). When copying from a remote server to a local host, you may wish simply to place the file(s) in the current directory. To do this, you should specify a target of .. For example:

pscp fred@example.com:/home/tom/.emacs .

…would copy /home/tom/.emacs on the remote server to the current directory.

As with the source parameter, if the target is on a remote server and is not a full path name, it is interpreted relative to your home directory on the remote server.

5.2.2 Options

PSCP accepts all the general command line options supported by the PuTTY tools, except the ones which make no sense in a file transfer utility. See section 3.8.3 for a description of these options. (The ones not supported by PSCP are clearly marked.)

PSCP also supports some of its own options. The following sections describe PSCP’s specific command-line options.

5.2.2.1 -ls list remote files

If the -ls option is given, no files are transferred; instead, remote files are listed. Only a hostname specification and optional remote file specification need be given. For example:

pscp -ls fred@example.com:dir1

The SCP protocol does not contain within itself a means of listing files. If SCP is in use, this option therefore assumes that the server responds appropriately to the command ls -la; this may not work with all servers.

If SFTP is in use, this option should work with all servers.

5.2.2.2 -p preserve file attributes

By default, files copied with PSCP are timestamped with the date and time they were copied. The -p option preserves the original timestamp on copied files.

5.2.2.3 -q quiet, don’t show statistics

By default, PSCP displays a meter displaying the progress of the current transfer:

mibs.tar          |   168 kB |  84.0 kB/s | ETA: 00:00:13 |  13%

The fields in this display are (from left to right), filename, size (in kilobytes) of file transferred so far, estimate of how fast the file is being transferred (in kilobytes per second), estimated time that the transfer will be complete, and percentage of the file so far transferred. The -q option to PSCP suppresses the printing of these statistics.

5.2.2.4 -r copies directories recursively

By default, PSCP will only copy files. Any directories you specify to copy will be skipped, as will their contents. The -r option tells PSCP to descend into any directories you specify, and to copy them and their contents. This allows you to use PSCP to transfer whole directory structures between machines.

5.2.2.5 -batch avoid interactive prompts

If you use the -batch option, PSCP will never give an interactive prompt while establishing the connection. If the server’s host key is invalid, for example (see section 2.2), then the connection will simply be abandoned instead of asking you what to do next.

This may help PSCP’s behaviour when it is used in automated scripts: using -batch, if something goes wrong at connection time, the batch job will fail rather than hang.

5.2.2.6 -sftp, -scp force use of particular protocol

As mentioned in section 5.2.1, there are two different file transfer protocols in use with SSH. Despite its name, PSCP (like many other ostensible scp clients) can use either of these protocols.

The older SCP protocol does not have a written specification and leaves a lot of detail to the server platform. Wildcards are expanded on the server. The simple design means that any wildcard specification supported by the server platform (such as brace expansion) can be used, but also leads to interoperability issues such as with filename quoting (for instance, where filenames contain spaces), and also the security issue described in section 5.2.1.

The newer SFTP protocol, which is usually associated with SSH-2 servers, is specified in a more platform independent way, and leaves issues such as wildcard syntax up to the client. (PuTTY’s SFTP wildcard syntax is described in section 6.2.2.) This makes it more consistent across platforms, more suitable for scripting and automation, and avoids security issues with wildcard matching.

Normally PSCP will attempt to use the SFTP protocol, and only fall back to the SCP protocol if SFTP is not available on the server.

The -scp option forces PSCP to use the SCP protocol or quit.

The -sftp option forces PSCP to use the SFTP protocol or quit. When this option is specified, PSCP looks harder for an SFTP server, which may allow use of SFTP with SSH-1 depending on server setup.

5.2.2.7 -no-sanitise-stderr: control error message sanitisation

The -no-sanitise-stderr option will cause PSCP to pass through the server’s standard-error stream literally, without stripping control characters from it first. This might be useful if the server were sending coloured error messages, but it also gives the server the ability to have unexpected effects on your terminal display. For more discussion, see section 7.2.3.5.

5.2.3 Return value

PSCP returns an ERRORLEVEL of zero (success) only if the files were correctly transferred. You can test for this in a batch file, using code such as this:

pscp file*.* user@hostname:
if errorlevel 1 echo There was an error

5.2.4 Using public key authentication with PSCP

Like PuTTY, PSCP can authenticate using a public key instead of a password. There are three ways you can do this.

Firstly, PSCP can use PuTTY saved sessions in place of hostnames (see section 5.2.1.2). So you would do this:

  • Run PuTTY, and create a PuTTY saved session (see section 4.1.2) which specifies your private key file (see section 4.23.8). You will probably also want to specify a username to log in as (see section 4.15.1).
  • In PSCP, you can now use the name of the session instead of a hostname: type pscp sessionname:file localfile, where sessionname is replaced by the name of your saved session.

Secondly, you can supply the name of a private key file on the command line, with the -i option. See section 3.8.3.18 for more information.

Thirdly, PSCP will attempt to authenticate using Pageant if Pageant is running (see chapter 9). So you would do this:

  • Ensure Pageant is running, and has your private key stored in it.
  • Specify a user and host name to PSCP as normal. PSCP will automatically detect Pageant and try to use the keys within it.

For more general information on public-key authentication, see chapter 8.

Windows 10 now has OpenSSH built in.
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

Get an admin command prompt

Open PowerShell as an Administrator.

Check available versions

Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

Install client

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

Install server

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Start server and enable at boot

Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

Find your Windows IP address

ipconfig

On your remote (Linux) machine, find your IP address.

ifconfig

Create a public SSH key

ssh-keygen.exe

Copy public key from local (Windows) to remote (Linux) machine so you don’t have to type in a password all the time.

Note that ssh-copy-id is not currently available on Windows.

cat C:UsersYOU/.ssh/id_rsa.pub | ssh USER@REMOTE_IP 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'

Do the same on your Linux machine (Note, ssh-copy-id does not work)

ssh-keygen # if needed
cat ~/.ssh/id_rsa.pub | ssh USER@WINDOWS_IP 'mkdir -p ~/.ssh && type con >> C:/Users/YOU/.ssh/authorized_keys'
  • The method above did not work for me, so I ended up manually SCPing the public key over and pasting it into the C:/Users/YOU/.ssh/authorized_keys file.

  • That still did not work, so I had to modify the sshd_config file.

    • Open Notepad as Administrator

    • Open %programdata%sshsshd_config

    • Add the following lines:

        Match User YOU
             AuthorizedKeysFile C:/Users/YOU/.ssh/authorized_keys
  • Reboot

Create a password on Windows if you don’t already have one

System Settings...Sign-in options

— Note, you can still disable the Windows login screen by a) Setting the ‘Require sign-in’ option to never and b) Using the ‘netplwiz’ command and unticking the ‘Users must enter password…’ checkbox.

Now you should be able to SSH or SCP from your Linux machine

scp FILE WINDOWS_IP:C:/Users/YOU/Desktop

В статье мы расскажем, как передать файлы через SSH на разных операционных системах — Windows и Linux.

  1. Что нужно для подключения
  2. Как скопировать файл через SSH на Linux
    • Как отправить файл по SSH с локального компьютера на сервер
    • Как скачать файлы с удаленного сервера на компьютер
  3. Как скопировать файлы по SSH на Windows
    • Как загрузить файл с компьютера на сервер
    • Как скачать файл через SSH на локальный компьютер

Для подключения к серверу вам потребуются:

  • IP-адрес или имя сервера,
  • логин пользователя (в том числе root),
  • пароль пользователя,
  • порт.

Чаще всего копирование файлов через SSH делают с помощью двух мини-программ:

  1. scp (Secure Copy) — утилита для Linux. Она позволяет безопасно передать или скачать файл по протоколу SSH. Программа scp входит в комплект OpenSSH и не требует установки.
  2. pscp.exe — это утилита для Windows. Она используется по тому же назначению, что и scp: подключение к серверу по SSH и работа с файлами. Эта мини-программа входит в состав PuTTY: ее можно скачать на официальном сайте. Процедура настройки SSH-клиента описана в нашей статье.

Важно: если загружаемый файл существует на целевом хосте, он перезапишется.

Работа через SSH предполагает использование консольных команд. Наиболее популярные из них вы можете найти в статье.

Как скопировать файл через SSH на Linux

Копирование файлов по SSH на Linux можно сделать с помощью scp. Эта утилита позволяет:

  • передать файл с локального компьютера на удаленный сервер,
  • скачать файл с удаленного сервера на локальный компьютер.

Команда scp имеет следующий синтаксис:

scp опция источник получатель

Как отправить файл по SSH с локального компьютера на сервер

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

scp /home/test.doc username@servername:/directory

Где:

  • /home/test.doc — путь к файлу на локальном компьютере;
  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • directory — директория на сервере, в которую нужно загрузить файл.

Готово, вы загрузили файл на сервер.

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

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

scp username@servername:/directory/test.doc /home

Где:

  • /directory/test.doc — путь к файлу на сервере;
  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • home — папка на компьютере, в которую нужно загрузить файл.

Готово, вы скачали файл на компьютер.

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

Копирование через SSH на ОС Windows выполняется с помощью утилиты pscp.exe из набора PuTTY.

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

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

pscp C:/documents/test.doc username@servername:/directory

Где:

  • /documents/test.doc — путь к файлу на локальном компьютере;
  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • directory — директория на сервере, в которую нужно загрузить файл.

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

pscp “C:/documents/test 1.doc” username@servername:/directory

Готово, вы загрузили файл на сервер.

Как скачать файл через SSH на локальный компьютер

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

pscp username@servername:/directory/test.doc C:/documents

Где:

  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • directory/test.doc — путь к файлу на сервере;
  • /documents — директория на локальном компьютере, в которую нужно загрузить файл.

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

pscp username@servername:”/directory/test 1.doc” C:/documents

Готово, вы скачали файл на компьютер.

To copy text from Putty to your Windows clipboard or program, here’s what to do.

  1. Left-click inside the PuTTY terminal window near the text you want to copy.
  2. Holding down the left mouse button, drag your cursor across the text to select it, then release the button to copy it.

20 дек. 2020 г.

How do I transfer files from Linux to Windows?

Using FTP

  1. Navigate and open File > Site Manager.
  2. Click a New Site.
  3. Set the Protocol to SFTP (SSH File Transfer Protocol).
  4. Set the Hostname to the IP address of the Linux machine.
  5. Set the Logon Type as Normal.
  6. Add the username and password of the Linux machine .
  7. Click on connect.

12 янв. 2021 г.

How copy file from Linux to Windows command line?

Here is the solution to copy files from Linux to Windows using SCP without password by ssh:

  1. Install sshpass in Linux machine to skip password prompt.
  2. Script. sshpass -p ‘xxxxxxx’ scp /home/user1/*.* testuser@x.x.x.x:/d/test/

12 мар. 2018 г.

Can I use PuTTY to transfer files?

PuTTY is a free open source (MIT-licensed) Win32 Telnet console, network file transfer application, and SSH client. Various protocols like Telnet, SCP, and SSH are supported by PuTTY. It has the ability to connect to a serial port.

How do I copy files from Linux to Windows using SCP?

  1. Step 1: Download pscp. https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html. …
  2. Step 2: Get familiar with the pscp commands. …
  3. Step 3: Transfer file from your Linux machine to Windows machine. …
  4. Step 4: Transfer file from your Windows machine to Linux machine.

How do I transfer files using PuTTY?

COPY: Simply highlight text in PuTTY. Press and keep pressed left mouse button + move mouse to highlight the text you want + release left mouse button and text will be copied to the clipboard.

Can I access Windows files from Linux?

Because of the nature of Linux, when you boot into the Linux half of a dual-boot system, you can access your data (files and folders) on the Windows side, without rebooting into Windows. And you can even edit those Windows files and save them back to the Windows half.

How do I transfer files from Linux to Windows using FTP?

How to Copy Files to a Remote System ( ftp )

  1. Change to the source directory on the local system. …
  2. Establish an ftp connection. …
  3. Change to the target directory. …
  4. Ensure that you have write permission to the target directory. …
  5. Set the transfer type to binary. …
  6. To copy a single file, use the put command. …
  7. To copy multiple files at once, use the mput command.

How do I copy files from Ubuntu to Windows?

you get a ftp-like interface where you can copy over files. The better approach would likely be to use rsync from the Ubuntu environment and copy the content to your Windows Share. You could use an SFTP client over SSH to transfer the files from your Ubuntu machine. Drag and drop folders works fine!

How do I copy files from Linux to Windows using MobaXterm?

File Transfer using MobaXterm

When you log in to a remote SCC session using SSH, a graphical SFTP (Secure File Transfer Protocol) browser appears in the left sidebar allowing you to drag and drop files directly to or from the SCC using the SFTP connection. To manually open a new SFTP session: Open a new session.

How do I copy a file to a local machine in Linux?

How to copy a file from a remote server to a local machine?

  1. If you find yourself copying with scp often, you can mount the remote directory in your file browser and drag-and-drop. On my Ubuntu 15 host, it’s under the menu bar “Go” > “Enter Location” > debian@10.42.4.66:/home/debian . …
  2. Give rsync a try. It’s great both for local and remote copies, gives you copy progress, etc.

How do I copy a file in Linux?

To copy files and directories use the cp command under a Linux, UNIX-like, and BSD like operating systems. cp is the command entered in a Unix and Linux shell to copy a file from one place to another, possibly on a different filesystem.

How do I download a file from PuTTY to local?

2 Answers

  1. Download PSCP.EXE from Putty download page.
  2. Open command prompt and type set PATH=<path to the pscp.exe file>
  3. In command prompt point to the location of the pscp.exe using cd command.
  4. Type pscp.
  5. use the following command to copy file form remote server to the local system pscp [options] [user@]host:source target.

12 нояб. 2014 г.

Can PuTTY FTP?

PSFTP, the PuTTY SFTP client, is a tool for transferring files securely between computers using an SSH connection. PSFTP differs from PSCP in the following ways: PSCP should work on virtually every SSH server. … PSFTP allows you to run an interactive file transfer session, much like the Windows ftp program.

Can you transfer files over SSH?

With rsync , you can transfer files and directories over SSH from and to remote servers. Where SRC is the source directory, DEST is the destination directory USER is the remote SSH username and HOST is the remote SSH host or IP Address.

How to transfer files between a Windows and a Linux Machine

calendar_today

Updated On:

Issue/Introduction

Resolution

Contents:

Linux to Windows
Windows to Linux

From Linux to Windows

Note:  WinCP or Putty may be used, the below example, PSCP (Putty) will be used.

1.       Download and install Putty onto the workstation.

2.       Open a Command Prompt terminal and change directories to the Putty-installation-path.

Tip: Browse to the Putty installation path C:Program Files (x86)Putty using the Windows Explorer.  Once in the directory, while holding the shift-key right-click anywhere in the window and select Open command window here. WinCP and Filezilla offer a graphical user interfaces (GUI) to transfer files between Linux and Windows.

3.       Enter the following line, replacing the <variable> items:
pscp.exe [email protected]<RemoteHost>:<RemoteDirectory>/* C:

From Windows to Linux

Note:  WinCP or Putty may be used, the below example, PSCP (Putty) will be used.

1.       Download and install Putty onto the workstation.

2.       Open a Command Prompt terminal and change directories to the Putty-installation-path.

Tip: Browse to the Putty installation path C:Program Files (x86)Putty using the Windows Explorer.  Once in the directory, while holding the shift-key right-click anywhere in the window and select Open command window here. WinCP and Filezilla offer a graphical user interfaces (GUI) to transfer files between Linux and Windows.

3.       Enter the following line, replacing the <variable> items:
pscp.exe <LocalFilePath> <user>@<RemoteHost>:<RemoteDirectory>

Tip: Simply drag the file, to be transferred, into the Command Prompt window after typing pscp.exe; this will automatically populated the <LocalFilePath>.

For example:

Attachments

Feedback

thumb_up
Yes

thumb_down
No

Подключение к серверу посредством SSH – один из основных методов управления *nix серверами. Довольно часто возникает необходимость загрузить файл на удаленный сервер, либо выгрузить, и других средств кроме SSH-подключения нет. К счастью, копирование файлов через защищенное соединение – одна из штатных функций этого протокола и реализуется с помощь отдельной команды scp в Linux-системах, либо с помощью pscp.exe, входящей в состав SSH-клиента Putty для операционной системы Windows.

Работаем на ОС семейства Linux

Используем следующий формат команд:

scp [модификатор] [источник] [место_назначения]

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

[пользователь]@[сервер]:[путь_к_файлу]

После запуска команды потребуется ввести пароль от указанной учетной записи удаленного сервера.

Если собрать все вместе, то скопировать локальный файл /home/user/file.tgz в домашний каталог пользователя root удаленного сервера 123.123.123.123 можно командой:

scp /home/user/file.tgz root@123.123.123.123:/root

Чтобы скачать этот же файл с удаленного сервера:

scp root@123.123.123.123:/root/file.tgz /home/user

За одну операцию можно скопировать несколько файлов, для этого необходимо указать их в качестве источника, разделив пробелом – местом назначения будет считаться последний указанный параметр. Например, загрузить файлы file1.tgz и file2.tgz из локального каталога на удаленный сервер позволит команда:

scp file1.tgz file2.tgz root@123.123.123.123:/root

Для копирования каталога потребуется задействовать модификатор команды r. Копируем локальный каталог /home/user/dir на удаленный сервер:

scp –r /home/user/dir root@123.123.123.123:/root

В тех случаях, когда SSH-сервер работает на нестандартном порту, поможет опция P. Если нужно подключиться через порт 10022:

scp –P 10022 /home/user/file.tgz root@123.123.123.123:/root

Чтобы узнать какие еще модификаторы поддерживает команда, можно просто запустить scp без параметров и прочитать краткую справку.

Работаем на ОС семейства Windows

При использовании операционной системы Windows и Putty в качестве клиента, формат команды остается тот же, меняется только название исполняемого файл и используется синтаксис указания путей к файлам и каталогам Windows при указании источника или места назначения. Запускаем командную строку (cmd.exe) или PowerShell, переходим в каталог, где расположен файл pscp.exe вводим команду:

pscp.exe C:Tempfile.tgz root@123.123.123.123:/root

В случае запуска из какой-либо другой папки понадобится указать полный путь к pscp.exe. Если в каком-либо из путей присутствуют пробелы, используются двойные кавычки — “Путь к файлу”:

“C:Program FilesPuttypscp.exe” C:Tempfile.tgz root@123.123.123.123:/root

Как и в случае с scp, запустив pscp.exe без параметров, можно увидеть краткую справку по синтаксису команды и перечень поддерживаемых модификаторов.

Запуск команд на удаленном сервере через SSH-подключение

Протокол SSH, помимо работы в интерактивном режиме, поддерживает также разовый запуск команд или скриптов на удаленном сервере.

Работаем на ОС семейства Linux

Синтаксис команды:

ssh [пользователь]@[сервер] ‘[команда]’

При запросе вводим пароль указанного пользователя и в консоли получаем вывод команды, если таковой имеется.

Например, получим информацию об установленной на удаленном сервере операционной системе:

ssh root@123.123.123.123 ‘uname -a’

Чтобы запустить несколько команд за одно подключение, можно использовать символ “;” в качестве разделителя. Проверим сетевые настройки и активные сетевые подключения на удаленном сервере:

ssh  root@123.123.123.123 ‘ifconfig; netstat -anp tcp’

В случае, если потребуется запустить на удаленном сервере локальный файла сценария, потребуется в SSH-подключении вызвать командный интерпретатор в режиме исполнения сценария (например, bash с ключом -s), и на стандартный ввод передать ему файл сценария. Выглядеть эта конструкция будет так:

ssh  root@123.123.123.123 ‘bash -s’ < /home/user/myscript.sh

В результате локальный файл /home/user/myscript.sh исполнится на удаленном сервере.

Запуск команды SSH без параметров позволит ознакомиться с краткой справкой по синтаксису и списком дополнительных модификаторов, которые позволяют расширить функциональность команды.

Работаем на ОС семейства Windows

Если мы подключаемся к удаленному серверу с компьютера, работающего на операционной системе Windows, то нам снова потребуется обратиться к терминальному клиенту Putty, в состав которого входит исполняемый файл plink.exe. Работать с этим файлом необходимо из командной строки (cmd.exe) или из PowerShell.

Для запуска команды на удаленном сервере используется следующий синтаксис:

plink.exe [сервер] -ssh -l [пользователь] “[команда]”

Проверим конфигурацию сетевых интерфейсов:

plink.exe 123.123.123.123 -ssh -l root “ifconfig”

Как и при работе с командой SSH в Linux, plink.exe позволяет использовать “;” в качестве разделителя для запуска нескольких команд:

plink.exe 123.123.123.123 -ssh -l root “ifconfig; netstat -anp tcp”

А запуск команд из локального файла можно реализовать с помощью дополнительного ключа m:

plink.exe 123.123.123.123 -ssh -l root -m “C:Tempmyscript.sh”

Запустив команду plink.exe без параметров, можно ознакомиться с краткой справкой по синтаксису и списком дополнительных модификаторов команды.

Аverage rating : 4

Оценок: 8

191028
Санкт-Петербург
Литейный пр., д. 26, Лит. А

+7 (812) 403-06-99

700
300

ООО «ИТГЛОБАЛКОМ ЛАБС»

191028
Санкт-Петербург
Литейный пр., д. 26, Лит. А

+7 (812) 403-06-99

700
300

ООО «ИТГЛОБАЛКОМ ЛАБС»

700
300

Понравилась статья? Поделить с друзьями:
  • Purble place скачать бесплатно для windows 10 торрент
  • Purble place как скачать на windows 10
  • Purble place как найти на компьютере windows 10
  • Pupg mobile скачать на компьютер windows 7
  • Pup optional legacy как удалить в windows 10