- WinSCP работаем с файлами Linux сервера через SFTP
- Скачиваем программу
- Устанавливаем WinSCP
- Запускаем программу и подключаемся к серверу
- Подтверждаем сертификат
- Попадаем в интерфейс взаимодействия с сервером
- Заливаем файлы
- How can I move files from Windows to Linux using WinSCP?
- 8 Answers 8
- Use WinSCP commandline to copy from Windows to Linux
- SCP copy windows local file to linux remote folder
- 11 Answers 11
- Как получить удаленный доступ к файловой системе Linux из Windows. WinSCP.
WinSCP работаем с файлами Linux сервера через SFTP
Админите линуксовые сервера с мастдая? Дело достаточно распространенное ибо должен же админ хоть иногда играть в какие-нибудь игрушки, а что для этого подходит лучше чем мастдай? Ничего абсолютно :). Но вернемся к насущному вопросу. Как удобнее всего перемещать файлы на линуксовый хост и обратно когда он не оснащен гуём? Какой-нибудь сервер у которого из средств управления только терминал, или хостинг вашего сайта куда например надо залить большое количество сайтов чтобы развернуть там какую-нибудь CMS? Когда вариант открыть нужный сайт через тот же браузер и скачать файл как делают простые смертные не реализуем? 99% что у такого хоста открыт 22й порт и вы устанавливаете с ним соединение через SSH. А значит 99% что вы сможете передавать на этот хост файлы по протоколу SFTP который работает поверх SSH. Для этого мы и будем использовать программу WinSCP.
Скачиваем программу
Качаем с официального сайта
Устанавливаем WinSCP
Установить программу не сложнее чем Putty. Я всегда ставлю не меняя стандартные настройки прямиком в Program Files
Запускаем программу и подключаемся к серверу
Видим следующее окно:
Подключение к серверу
Чтобы авторизоваться на вашем сервере через протокол SFTP нужны те же реквизиты что и для того чтобы авторизоваться на нем через SSH. Логин + Пароль + адрес сервера + порт SSH
Подтверждаем сертификат
В том случае, если подключюение к текущему серверу устанавливается впервые и у вас небыл ранее импортирован его сертификат, WinSCP оповестит вас об этом. Подтверждаем и идём дальше
Попадаем в интерфейс взаимодействия с сервером
Левая часть – локальный компьютер, правая часть – удаленный сервер. Файлы можно перемещать обычным перетаскиванием
Заливаем файлы
Зальем на удаленный хост например дистрибутив 1ски и постгрес
По окончании загрузки, мы уже можем работать с файлами на нашем удаленном хосте
Так же в программу можно импортировать соединения из putty. Совместное использование WinSCP + Putty – покрывает практически все повседневные нужды с которыми можно столкнуться в процессе развертывания серверов. Так же, если вы работаете по SSH с серверами за пределами вашей локальной сети, крайне рекомендуется использовать для авторизации на сервере не пароль а сертификат, а парольную авторизацию отключить вообще.
How can I move files from Windows to Linux using WinSCP?
I have PuTTY and WinSCP, but WinSCP doesn’t work in this case because I need to use a command cd ../public in order to enter the directory as I can’t find it for some reason.
How would I use PuTTY or the command prompt to copy Windows files onto a Linux server? Would cat work in copying and pasting the file over?
8 Answers 8
Do you have physical access to both computers? Can you “sneakernet” the files (i.e., copy them to some portable storage device, such as a flash drive, and carry it to the other machine)?
I think I would use Rsync from PuTTY on Windows.
The benefit of using Rsync is knowing that Windows is likely to need to be restarted part-way through the file copying if there is a significant number of files, at least if using Rsync, you won’t have to start the copy process all over again.
Rsync can work over NFS, SSH, and even Samba (and others), so no reason why this won’t work.
This is a sample of how the command might look:
Welcome to Linux!
If you can read the files in PuTTY, you can copy them with WinSCP:
- navigate to the folder where your files are using cd
- run pwd -P
- start WinSCP
- navigate to the folder as indicated in step 2.
- mark desired files, copy them to the local target folder
- enjoy a coffee break
If you insist on CLI, then rsync is a far superior option to scp . First you need to figure out where your files are (see step 1. and 2. above). When you have that, copying files is a simple matter of:
Use enduradata’s file transfer: http://www.enduradata.com (the demo license has all the functionality you need). It will handle open files as well.
I am not sure what you mean by WinSCP not working. Are you referencing to the command line function of WinSCP or something similar that I don’t know?
But in any case, if you have PuTTY, you should have pscp in the same directory, which stands for putty-scp. Make sure the pscp executable is somewhere in the search path of Windows, and then do:
Here you are going to be asked the password for the user you specified on the pscp line.
There are different switches for pscp, but without knowing what you are exactly doing, it is hard to tell which ones to use what way.
Use WinSCP commandline to copy from Windows to Linux
WinSCP is a great Windows GUI utility to copy files to and from Linux boxes, but many don’t know about the powerful WinSCP commandline functionality that are extremely useful to setup jobs to periodically copy files from Windows over to Linux or vice versa. All it takes is the correct syntax to call the executable and then switches to perform the actions you want to perform.
Recently, in working with a client who wanted to feed a web service a CSV file from a directory on a Windows box, they ran into issues trying to get the service to read the remote file. However, in suggesting using WinSCP to first copy the file over to the Linux box and then have the web service read the current file locally, this resolved the issue they were seeing.
Let’s take a look at the syntax required to call the WinSCP program and tell it to SCP a file from Windows to Linux.
Syntax and switches
The command above first calles the winscp.com file from the program directory and feeds it the options we want. The option confirm off switch tells it that we don’t want it to make us confirm things like file overwrites and such as we want to use this with a scheduled task. Then we simply are pointing it to Linux server in question and telling it which local Windows file we want to send over to the web directory on the Linux server. The final exit command simply exits the winscp program and sends us back to the prompt which finishes our batch file.
Scheduled Task
The last order of business is to simply setup a scheduled task run the batch or exe that we create containing the scripted winscp.com.
- Create Basic Task
- Point it to the batch with the winscp.com script
- Set your schedule
- Make sure you have the options enabled to Run with highest privileges
- And the option Run whether user is logged on or not
The above options will make sure the script doesn’t run into system rights issues, as well as will make sure the program runs whether there is a user logon session running or not.
Final Thoughts
WinSCP although not really known as well for its commandline potential, is a great way to schedule file copies from Windows to Linux boxes or for other system admin tasks.
SCP copy windows local file to linux remote folder
How to get a file from my path d:/test.txt and copy it to /etc/var/test/test.txt
but that didn’t worked, how to set the hard disk from where I copy my files?
11 Answers 11
Umm, if you’re using cygwin you want that command to look like
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.
You can refer the following blog post for more information on pscp setup.
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;
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 из Windows. WinSCP.
Иногда бывает нужно получить доступ с компьютера под управлением Windows к файловой системе на компьютере Linux , но нет возможности поставить samba или FTP . Да и расшаривать самбой или фтп корень системы, мягко говоря, не безопасно. На этот случай можно воспользоваться небольшой, но очень полезной программой – WinSCP .
Скачать программу можно ]]> здесь ]]>
Она поддерживает следующие протоколы – sftp , scp , ftp , webdav . Я покажу ее работу на примере scp протокола.
Все что нужно – доступ к компьютеру по SSH . Подключаемся к нашему компьютеру, вводим адрес, порт, выбираем протокол передачи, по желанию можно сохранить подключение. Адрес у меня стоит 127.0.0.1, т.к. подключаюсь через SSH туннель. О том как его настроить читайте в этой статье.
После того как необходимые параметры введены, жмем кнопку войти.
Вводим наш пароль если, не сохраняли его в первом окне.
Откроется окно, привычное всем пользователям таких файловых менеджеров как Total Commander . В левой части располагаются ресурсы локального компьютера, в правой – удаленного.
Для того что бы что-либо скопировать нужно выбрать файл, или несколько файлов и нажать F 5, для удаления используется клавиша F 8, возможно редактирование файлов встроенным редактором без копирования.