Перейти к содержимому

Как через putty передать папку

  • автор:

Как копировать и передавать файлы по SSH

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

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

  • 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. Эта утилита позволяет:

Copy files from/to remote server using PuTTY pscp

Akshay Waingankar

PuTTY is a free and open-source terminal emulator and network file transfer application. This application helps us to handle server environment with commands on the Linux operating system.

In this article, we will see how to transfer files from localhost to server or vice a versa on Linux operating system. For that, you need to install PuTTY and PSCP( PuTTY Secure Copy client to transfer files using SSH) as per your machine configuration. Link below

Download PuTTY: latest release (0.74)

This page contains download links for the latest released version of PuTTY. Currently this is 0.74, released on…

Once you install and setup PuTTY application you need to login to your server with hostname and port number details. Install PSCP as well and login to PuTTY terminal.

Transferring file from localhost to server

Here 22 is a port number which is common in most of the cases. You can transfer files as well as zip folder. In my case, I am sending entire application files through the zip folder. Once you run this command, it will prompt for the password and you need to enter SSH password over here. Zip file will copy inside public_html folder at the remote server location.

It will show you the progress of file transferring, once it reaches 100% you can check that file using PuTTY by going to that folder and checking all files by typing

Transferring file from server to localhost

It will ask for the password. Provide SSH password and file will start downloading to the folder location where your common prompt is pointing.

Bonus point

If you pull zip file, then unzip it and delete it after all files are deployed to a remote location

Hopefully, you guys are clear about the file transfer process. Check out my other articles as well.

Transfer files to/from session I'm logged in with PuTTY

What is the command to transfer files from my local machine to the machine I’m logged into on PuTTY?

blue-sky's user avatar

13 Answers 13

This is probably not a direct answer to what you’re asking, but when I need to transfer files over a SSH session I use WinSCP, which is an excellent file transfer program over SCP or SFTP. Of course this assumes you’re on Windows.

  • Click on start menu.
  • Click run
  • In the open box, type cmd then click ok
  • At the command prompt, enter:

  • When promted, enter your password for server.

S.L. Barth is on codidact.com's user avatar

PuTTY usually comes with a client called psftp which you can leverage for this purpose. I don’t believe you can do it through the standard PuTTY client (although I may be proven wrong on that).

PuTTY only gives you access to manipulate the remote machine. It doesn’t provide a direct link between the two file systems any more than sitting down at the remote machine does.

Peter Mortensen's user avatar

corsiKa's user avatar

You can also download psftp.exe from:

When you run it you type:

(Type help to get a full list of commands.)

You can also type get <file name> to download files from a remote machine to the local machine.

Peter Mortensen's user avatar

There’s no way to initiate a file transfer back to/from local Windows from a SSH session opened in PuTTY window.

Though PuTTY supports connection-sharing.

While you still need to run a compatible file transfer client (the pscp or psftp ), no new login is required, it automatically (if enabled) makes use of an existing PuTTY session.

Alternative way is to use WinSCP, a GUI SFTP/SCP client. While you browse the remote site, you can anytime open SSH terminal to the same site using Open in PuTTY button.

With an additional setup, you can even make PuTTY automatically navigate to the same directory you are browsing with WinSCP.

(I’m the author of WinSCP)

Since you asked about to/from, here’s a trick that works for the ‘from’ part. Open the ‘Change settings. ‘ screen, Terminal, and under ‘Printer to send ANSI printer output to:’ select ‘Generic / Text Only’

Now on the remote system, run this on one line:

Putty will inform you that the file was saved. What this is doing is putting the terminal into printer mode (tput mc5), printing the file to the screen (cat), and then turning off printer mode (tput mc4). If you don’t put all the commands on one line, the screen will appear frozen because Putty is saving all terminal output to a file in the background.

If you’re on a more limited system that doesn’t have the tput command (e.g. a qnap), you can try printf «\x1b[5i» instead of tput mc5, and printf «\x1b[4i» instead of tput mc4.

The command in the middle is just anything that prints to the screen. So use tail -n 10000 blah.log to download the last 10k lines of the log file, or use a base64 encoder to map a binary file to something you can print (and then decode on your local system):

If it is only one file, you can use following procedure (in putty):

  1. vifilename.extension (opens new file name in active folder on server),
  2. copy + mouse right click while over putty (copy and paste),
  3. edit and save. =>vi editor commands

Edit file permission with next command: chmod u+x filename.extension

If you have to do private key validation; at Command Prompt(cmd), run

Also, if you need extra options look at the following link. https://the.earth.li/

ÖMER TAŞCI's user avatar

It recommends using pscp.exe from PuTTY, which can be found here: https://www.chiark.greenend.org.uk/

A direct transfer like FTP is not possible, because all commands during your session are send to the server.

Transfering files with Putty

This blog introduces how to use `Putty` to transfer files from Windows OS to Linux OS and reverse.

During my daily working, I do the development on Windows OS; besides, we have a Debian server for running different jobs automatically, file storage, etc. Sometimes, we also need to transfer files from Windows OS to Linux OS, or reverse; in this case, we use Putty to realize the transfering. Today, I will talk about how to use Putty for transfer files with the following points:

  • What is Putty ?
  • Requirements
  • Transfering files from Windows to Linux
  • Transfering files from Linux to Windows

What is Putty ?

PuTTY is a free and open-source terminal emulator, serial console and network file transfer application. It supports several network protocols, including SCP, SSH, Telnet, rlogin, and raw socket connection. It can also connect to a serial port. The name “PuTTY” has no official meaning.

Requirements

  • Windows OS
  • Linux OS
  • Putty installed: download Putty here
  • Putty PSCP installed: download Putty PSCP here

Transfering files from Windows to Linux

To transfer files from Windows OS to Linux OS, we will apply PSCP . Before we start, let’s have a general understanding of it. PSCP means “PuTTy Secure Copy Protocol (PSCP)”, is a tool for transferring files securely between computers using an SSH connection. To use this utility, we should be comfortable working in the Windows Command Prompt.

Now, let’s start to transfer files to Linux:

  • Open Windows Command Prompt.
  • Type pscp source_path user_name@host:target_path at the prompt

Wins to Linux 1

Here, ./weekly_report.xlsx specifies the path of source file, xxx is user’s account for accessing the Linux server, 123.456.789.0 is the host address, /reporting presents target path.

  • After the bash script above, we also need to type the password for accessing the Linux server.

Wins to Linux 2

Transfering files from Linux to Windows

Transfering files from Linux OS to Windows OS is similar to the steps above:

  • Open Windows Command Prompt.
  • Type pscp user_name@host:source_path target_path at the prompt

Linux to Wins 1

  • Same as above, after the bash script above, we also need to type the password for accessing the Linux server.

Linux to Wins 2

Conclusion

In this blog, I introduced how to use Putty to transfer files from Windows OS to Linux OS and reverse. Hope it’s useful for you.

Reference

  • “PuTTY”, wikipedia. [Online]. Available: https://en.wikipedia.org/wiki/PuTTY
  • “Transfer Files Using PuTTY”, it.cornell.edu. [Online]. Available: https://it.cornell.edu/managed-servers/transfer-files-using-putty
  • Comfreak, “traffic information superhighway”, pixabay.com. [Online]. Available: https://pixabay.com/photos/traffic-information-superhighway-3524185/

This work is licensed under a Attribution-NonCommercial 4.0 International license. alt=»Attribution-NonCommercial 4.0 International» />

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *