Smbclient-


#1

hi all,

its possible to copy files from windows to linux which are only available when I use a Windows Environment Variable in the command line? because What I try to copy is not all time on the same place?

thanks in advance,

Regards,
Neeloj


#2

Please try to give an example. I don’t understand what you’re trying to accomplish. A kind of rsync between Windows and Linux?


#3

thanks for your answer @Wolfgang.

so I want to access a path which is saved under %mypath%, on windows cmd I can say cd %mypath% it will pass me to the path.

I want to copy files only from windows to linux and the folder is not shared-network-folder.

How can I achieve that? smbclient or rsync or is there another tool?


#4

Using ftp might work. It runs on Windows, %mypath% is a Windows variable and Linux mostly has a running ftp server.


#5

thanks @Wolfgang, Ill look at FTP, I dont know if FTP can access the path when I say: cd %mypath%


(gerhardg) #6

i would recommend scp, on the latest version its already an os feature => https://github.com/PowerShell/Win32-OpenSSH


#7

thanks for your answer @gerhardg,

That mean I have to acivate that feature on the OS right ?
Can I access Windows Environment Variable when I use scp ?


(gerhardg) #8

If you run the latest release, take a look with:

Get-WindowsCapability -Online | ? Name -like ‘OpenSSHUtils*’

If you run something older, simple try pscp.exe https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Both works with variables.


#9

thank you so much @gerhardg,
my last question please:

my idea is to copy files from Folder-A which is in %mypath% (I cant write the path because on every machine is on different place) on windows machine to Linux machine (Ubuntu 16.04 LTS), your example will work for this scenarios?


#10

Using pscp (as @gerhardg proposed) part of the output is:

PuTTY Secure Copy client
Release 0.70
Usage: pscp [options] [user@]host:source target
       pscp [options] source [source...] [user@]host:target
       pscp [options] -ls [user@]host:filespec

so pscp %mypath%/file user@linux:/target is very close to what you’re seeking.


#11

thank you so muvh @Wolfgang,

thats right, but I want do that on the Linux side and not from windows, because I have one Linux Server and 500+ Windows-Hosts and I have do that on each one, because of that Im looking to a solution to do that on the Linux side, its 1:500+

I hope you get my point now :see_no_evil: :flushed:


#12

Describing “I have a Linux session and want to copy files from Windows machines using the Windows environment variable %MYPATH% containing the source folder” would have been much clearer.
@gerhardgs answer seems that he’s been mislead, too.

Unless you have a process/daemon (like an FTP Server) on the Windows machines responding to your requests I’d say it’s not possible.


#13

sorry it was maybe my mistake!

this is also new for me thank you so much and it works! :+1:

Its not possible to start the pscp command from linux to windows ?

thanks again @Wolfgang


#14

There has to be a process on Windows responding to the requests. pscp is a Windows program, scp the corresponding Unix/Linux program. You probably have no SSH process running on the Windows machines so the answer is No.


#15

thanks I get it :slight_smile:


(gerhardg) #16

Take a look on „winexe“, there os also a update campain goin on:

An other option would be ssh, microsoft provide an port based on openssh: https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH


#17

thanks @gerhardg

I’ll test WinExe and I hope it will works :+1:

@gerhardg did you use that before ?


(gerhardg) #18

only sometimes in the last 8-9 years. there is already a fork with smb2 support, so it should still work with “modern” windows versions. be prepared that some antivirus/atp solutions may block winexe.

in the long run i would recommend ssh, microsoft is pushing it to secure psremoting from linux 2 windows.


#19

This is exactly what’s happen to me :frowning:

So I have to test smb2 and then maybe ssh or I’ll give up :wink: