Rsync from local linux to remote windows server - rsync

I am trying to copy files from local Linux server to remote windows file server using rysnc and sshpass but getting error
code
rsync --rsh='/usr/bin/sshpass -p 'password' ssh -p 139 -o StrictHostKeyChecking=no -l user' /x/y/z/ user#x.x.x.x:/a/b/c/
output
ssh_exchange_identification: Connection closed by remote host
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
Can anyone help?

Related

rsync command is giving error No such file or directory (2)

I am trying to transfer a file using in remote desktop which will create the directory tree as well in remote desktop as specified.I am using below command but its not working when directory is not present in remote server.
rsync -avzhe ssh --progress /root/BP/temp/temp.txt root#host2:/root/BP/temp2
Where /root/BP/temp/temp.txt is available in local but /root/BP/temp2 this path is not peresent in remote server.
I am getting below error :
rsync: change_dir#3 "/root/BP" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(625) [Receiver=3.0.9]
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
If you need to move files to a non existent path on the remote server, you must either:
Model the path and file structure locally and sync a common "ancestor".
This is requires only 1 step
Create the missing directories locally and sync them first then sync the files.
This requires 2 steps
To use the OP's specific example of:
rsync -avzhe ssh --progress /root/BP/temp/temp.txt root#host2:/root/BP/temp2
You would instead do:
# assuming that /root already exists on the remote server
mkdir -p /root/BP/temp/or_wherever/BP/temp2
mv /root/BP/temp/temp.txt /root/BP/temp/or_wherever/BP/temp2
rsync -avzhe ssh --progress /root/BP/temp/or_wherever/BP root#host2:/root/
But if for some reason you cannot move the file in question, you must use the second option:
# assuming that /root already exists on the remote server
mkdir -p /root/BP/temp/or_wherever/BP/temp2
# Notice there is no `/` after the `or_wherever/BP` in the next command
rsync -avzhe ssh --progress /root/BP/temp/or_wherever/BP root#host2:/root/
rsync -avzhe ssh --progress /root/BP/temp/temp.txt root#host2:/root/BP/temp2/

Why do I get this error while running rsync?

I'm trying to transfer my file from localhost to server using rsync. But this is what happens
abc#abc_def:~$ rsync -v -e ssh textfile.txt
abc#123.45.67.890:/home/test
ssh: connect to host 123.45.67.890 port 22: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]
abc#abc_def:~$
oops there was a mistake in the command just now i had cleared and it working now.
rsync -av -P -e 'ssh -p 1111' text.txt abc#123.45.67.890:/home/abc

Rsync fails when escaping parameters

I am currently testing rsync in order to synchronize some file between two servers.
When I espace the parameters of my command line with single quote, rsync seems to failed:
'rsync' '--recursive' '--verbose' '--archive' '--copy-dirlinks' '--rsh="ssh -i /path/to/my/key"' '--delete' '/path/to/my/source/directory' 'user#server:/path/to/my/destination/directory'
rsync: Failed to exec ssh -i /path/to/my/key: No such file or
directory (2) rsync error: error in IPC code (code 14) at pipe.c(85)
[sender=3.1.2] rsync: connection unexpectedly closed (0 bytes received
so far) [sender] rsync error: error in rsync protocol data stream
(code 12) at io.c(226) [sender=3.1.2]
But when I do not escape the parameters, rsync works correctly:
rsync --recursive --verbose --archive --copy-dirlinks --rsh="ssh -i /path/to/my/key" --delete /path/to/my/source/directory user#server:/path/to/my/destination/directory
I am using the 3.1.2 version.
I am doing something wrong ?

rsync delete option not working

rsync is not deleting files from destination directory, though Adding/modifying files working properly .
When I am using below command, i am getting below error :
[MS-PROD-FTP]$rsync -rave --del "ssh -i $cert" $Local_Dir/*
$USER#$Remote_Hostname:$Remote_Dir**
rsync: Failed to exec --del: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(600) [sender=3.0.6]
Below command one executed with no error ,But files are not getting deleted in dest directory .
[MS-PROD-FTP]$rsync --del -rave "ssh -i $cert" $Local_Dir/*
$USER#$Remote_Hostname:$Remote_Dir**
sending incremental file list
sent 136 bytes received 12 bytes 296.00 bytes/sec
total size is 66 speedup is 0.45
Can someone help here ?
The issue was /* , correct command is :
rsync -rave --del "ssh -i $cert" $Local_Dir/ $USER#$Remote_Hostname:$Remote_Dir/
Thanks ,

Need to Run batch script in UNIX server and display the output through vbscript

I am currently developing the new VBScript to execute the Shell (through Putty software) in UNIX server,
Set shell = WScript.CreateObject("WScript.Shell")
shell.Exec D:\Putty.exe hostname -l username -pw password 1.sh
I am getting connection refused error.
when I run the below command without my script (1.sh)
shell.Exec D:\Putty.exe hostname -l username -pw password
Connection is getting established without any issues.
Also, I just wanted to extract the output, once extracted, the session should get closed automatically.
This doesn't work in putty.exe. Putty has however a dedicated program to do these kind of things, it's called plink.exe - there you can pass commands and read the output just as you would expect, and your example should work just like you specified it.
PuTTY Link: command-line connection utility
Release 0.63
Usage: plink [options] [user#]host [command]
("host" can also be a PuTTY saved session name)
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-v show verbose messages
-load sessname Load settings from saved session
-ssh -telnet -rlogin -raw -serial
force use of a particular protocol
-P port connect to specified port
-l user connect with specified username
-batch disable all interactive prompts
The following options only apply to SSH connections:
-pw passw login with specified password
-D [listen-IP:]listen-port
Dynamic SOCKS-based port forwarding
-L [listen-IP:]listen-port:host:port
Forward local port to remote address
-R [listen-IP:]listen-port:host:port
Forward remote port to local address
-X -x enable / disable X11 forwarding
-A -a enable / disable agent forwarding
-t -T enable / disable pty allocation
-1 -2 force use of particular protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-m file read remote command(s) from file
-s remote command is an SSH subsystem (SSH-2 only)
-N don't start a shell/command (SSH-2 only)
-nc host:port
open tunnel in place of session (SSH-2 only)
-sercfg configuration-string (e.g. 19200,8,n,1,X)
Specify the serial configuration (serial only)

Resources