When a Windows Server is installed, You need to upload some files to the operating system. However, when this segment is only Linux, we can think of two methods:
- Use Remote Desktop to mount a local hard disk
- Transmission through the SSH service
However, in some cases, the Windows operating system is not customized through PXE, and Remote Desktop Connection is a multinational, so it is affected by the lack of SSH service or slow network speed of the other party. When you need to transmit a large file, you can only mount the local hard disk on the Remote Desktop. After a long wait, the system notifies you that the path cannot be found! Crash, and you have to hand over your fate to the network again ....
Is there a better way? The answer is yes, and there are not only many. Here we will introduce a method that is often ignored:
Escape the file to the local network, and then use smbclient to upload the file to the target Windows server.
Usage conditions:
- Enable the server service on Windows server to provide external sharing services
- Smbclient is installed on the source file server, which is usually installed by default.
- Access Windows shared directory permissions: user name and password
Usage
- View the shared directory of the target Windows Server
# Smbclient-l // 10.12.0.1/-uadministratorPassword:
Domain = [MyServer-55D13420A0] OS = [Windows Server 2003 R2 3790 Service Pack 2] Server = [Windows Server 2003 R2 5.2]
Sharename type comment
--------------------
IPC $ IPC? IPC
C $ disk Category Q?
ADMIN $ disk ??
Session Request to 10.12.0.1 failed (called name not present)
Session Request to 10 failed (called name not present)
Domain = [MyServer-55D13420A0] OS = [Windows Server 2003 R2 3790 Service Pack 2] Server = [Windows Server 2003 R2 5.2]
Server comment
----------------
Workgroup master
----------------
-
- Connect to the shared directory of the target Windows Server (the hidden share of the drive will be enabled after Windows is installed, and administrator permission is required. The access path is drive letter + $)
# Smbclient // 10.12.0.1/C $-uadministrator
Password: (enter the correct password)
Domain = [MyServer-55D13420A0] OS = [Windows Server 2003 R2 3790 Service Pack 2] Server = [Windows Server 2003 R2 5.2]
SMB: \> (if a prompt is displayed, the connection is successful)
- Upload files
SMB: \> put file1.rar (upload a single file)
SMB: \> mput file1.rar file2.rar (upload multiple files)
-
- Download files
SMB: \> Get file1.rar (download a single file)
SMB: \> mget file1.rar file2.rar (download multiple files)
-
- Change the remote shared directory
SMB: \> Cd DOC (relative to the shared directory)
-
- Use account permissions to connect and automatically execute commands
# Smbclient // 10.12.0.1/C $-u administrator % password-c "put file1; quit"
-
- More commands
? Chmod get listconnect mget posix_mkdir PWD rename stat vuid
Altname chown getfacl lock mkdir posix_open Q reput symlink wDEL
Archive close hardlink logon more posix_rmdir queue RM tar
Blocksize del help lowercase mput posix_unlink quit rmdir tarmode
Cancel dir history ls newer print RD setmode translate
Case_sensitive du LCD mask open prompt recurse showacls unlock
CD exit link md posix put reget showconnect volume
-
- Exit
SMB: \> quit
Note:
- An existing shared directory must exist after the connection path.
- The shared directory must have file access permissions.
- The parameters of the smbclient command must be placed after the machine name; otherwise, the command will be treated as the server address.
- After the file transfer is completed, you must immediately disable the server service for Windows to ensure system security.