rsync mkdir failed permission denied - ssh

I'm running PuTTy ssh on windows in the hope to copy a file from a remote server.
The command I used is below:
rsync -avz user#server:/home/user/imitate/tool /home/tool
But I received the error:
rsync: mkdir "/home/tool" failed: Permission denied (13)
rsync error: error in file IO (code 11) at main.c(605) [Receiver=3.0.9]
I'm totally new to this and I have no idea what is happening. So I logged into an account on a remote server using ssh, and want to copy files from that remote server to the laptop I'm using. What should I do?

you cannot write to /home/tool locally on your windows box. either run the command with more privileges or download to another directories where you have write permissions.

Related

VSCode Remote-SSH Cannot Connect

I'm trying to use the Remote-SSH extension to edit files on a Linux server from my Windows 10 development machine. Normally, I log into the server using VNC and edit files locally OR I use WinSCP to pull the files to my development machine and copy them back over when done. The Remote-SSH extension seems to be the answer to this inefficiency.
I can SSH just fine using Putty or using Git Bash, but Remote-SSH fails to connect. There's some hints in the error message, but I'm not sure how to interpret them.
Here is my SSH config file (redacted) and the error I receive (redacted):
Config:
Host xxx.yy.gov
HostName xxx.yy.gov
User myusername
Error Message:
[08:44:36.981] remote-ssh#0.47.2
[08:44:36.981] win32 x64
[08:44:36.983] SSH Resolver called for "ssh-remote+xxx.yy.gov", attempt 1
[08:44:36.983] SSH Resolver called for host: xxx.yy.gov
[08:44:36.983] Setting up SSH remote "xxx.yy.gov"
[08:44:37.030] Using commit id "[some-string-of-numbers]" and quality "stable" for server
[08:44:37.033] Testing ssh with ssh -V
[08:44:37.101] ssh exited with code: 0
[08:44:37.101] Got stderr from ssh: OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
[08:44:37.105] Running script with connection command: ssh -T -D 52772 xxx.yy.gov bash
[08:44:37.107] Install and start server if needed
[08:44:37.111] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[08:44:37.264] >
[08:44:37.264] Got some output, clearing connection timeout
[08:44:37.611] > myusername#xxx.yy.gov's password:
[08:44:37.612] Showing password prompt
[08:44:44.709] Got password response
[08:44:44.709] "install" wrote data to terminal: "**************"
[08:44:44.730] >
>
[08:44:45.102] > bash: bash: command not found
>
[08:44:45.476] "install" terminal command done
[08:44:45.476] Install terminal quit with output: bash: bash: command not found
[08:44:45.476] Received install output: bash: bash: command not found
[08:44:45.477] Stopped parsing output early. Remaining text: bash: bash: command not found
[08:44:45.477] Failed to parse remote port from server output
[08:44:45.477] Resolver error:
[08:44:45.480] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"UnparsableOutput",
"askedPw":"1","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","gotUnrecognizedPrompt":"0",
"remoteInConfigFile":"1"},"measures":{"resolveAttempts":1,"retries":1}}
[08:44:45.482] ------
VSCode Remote-SSH error
There are there are three ways you can try. I know the problem is annoying.
Check your vscode is local window or remote window. Then, check
remote-ssh setting. (Make sure Local Server Download is auto && Use
local Server is marked.).
Remote SSH:Path . you can switch to local ssh or git/ssh
Try to update or revert remote-ssh.(Version 0.50 can connect to server host stably, I found. This one is very useful.
Maybe you just select 'Linux' instead of 'Windows' though you are using Windows when you got the option to select Linux, Windows or Mac.
Since you are connecting to a server and not your own computer, the type of server you are connecting to is most likely Linux.

SCP log file to server

Hello I am trying to SCP a log file to serve and I keep getting error
Warning: Identity file ids-east-1.pem not accessible: No such file or directory.
ec2-11.com: Permission denied (publickey).
lost connection
I have tried all the solutions presented earlier but can't seem to figure out what's wrong.
The key I am using is :
scp -r -i ids-east-1.pem ~/int/resources/tests/tasks/lib/testing.log ec2-user#11.com:/home/wn/shelf/wrDb/fractions
Just a reminder- I am able to get a log file from this server using :
scp -i ids-east-1.pem ec2-user#11.com:/home/wn/shelf/wrDb/fractions/chrono.log ~/Desktop/aws_chrono.log
If one command works, but the other gives you:
Warning: Identity file ids-east-1.pem not accessible: No such file or directory.
You are likely not running the commands from the same directory. Try specifying the key path fully (something like):
scp -i ~/.ssh/ids-east-1.pem ...

Centos 6.5, WHM : Rsync with Root disabled using ssh user from the Wheel Group

I'm trying to rsync files with my server, which has root login via ssh disabled. I'm trying to use one of the users I've created and added to to the wheel group. Usually - when I log in via ssh I run
su - root
then type the password and can run everything as root user, but not quite sure how to do it with rsync as I need to upload the files outside of the user directory.
When I run:
rsync -avz files/* sshwheeluser#ip_address:/home/newproject/public_html/
I get:
rsync: ERROR: cannot stat destination "/home/newproject/public_html/": Permission denied (13)
I have added the following to the /etc/sudoers file:
rsyncuser ALL= NOPASSWD:/usr/bin/rsync
plus I've un-commented:
%wheel ALL=(ALL) NOPASSWD: ALL
I've also tried to run the command with –rsync-path="sudo rsync" as suggested in some posts, but still no luck:
rsync -avz –rsync-path="sudo rsync" files/* sshwheeluser#ip_address:/home/newproject/public_html/
Next I tried to use it with additional -e "ssh":
rsync -avz -e "ssh" –rsync-path="sudo rsync" files/* sshwheeluser#ip_address:/home/newproject/public_html/
which changed the error message (looks like we're getting somewhere):
stdin: is not a tty
sudo: sorry, you must have a tty to run sudo
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-40/rsync/io.c(452) [sender=2.6.9]
This post suggests that require_tty and tty_tickets should be disabled in sudoers, but I can't find these options in the /etc/sudoers file.
I've added (as recommended) Defaults !tty_tickets to the sudoers, but still the same message.
Any idea what else I need to do to make it work?
You should check Selinux logs, rsync is probably been blocked by Selinux.
You can also try to run:
semanage permissive -a rsync_t

Getting PSEXEC to run a local .vbs file on a remote machine without copying it over

I would like to get PSEXEC to run a .vbs file on a remote machine for me, however I currently have to have the .vbs located on the remote machine.
Below is an example of my script which does work.
psexec \\<\i.pAddress\> -u <\User\> -p <\Password\> -w c:\ -h cscript.exe "C:\Users\admin\Desktop\test.vbs"
Is there any solution which saves me having to place the test.vbs file on the remote machine before hand?
Use the -c option (http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx)
-c Copy the specified program to the remote system for execution. If you omit this option the application must be in the system path on the remote system.

Passing shell script file

I have a linux shell script file which collects various data from linux server. (Services, Process, FreeSpace etc.).
From windows to collect the data we are using Plink to connect to linux Boxes and run the shell script
plink root#servername -pw Password -noagent -m Batch-File.
and using pscp to copy the file to windows location.
Now when I try to do the same for Esxi the plink command fails with the error below.
FATAL ERROR: Server unexpectedly closed network connection
though If i give a direct command as below.
plink root#servername -pw Password -noagent ls /etc
works out.
Let me know how to use the plink for esxi .. if possible.
After seeing the messages log it looks like that the issue is with esxi's limitation to read long character string. The message log fails in the session with String Too Long and then post a message of closing the connection.
Thus the approach was to copy the shell script as a pscp connection, run the file with executable permission and collect the data gathered and delete the file from system.