I'm trying to send commands to start backup from windows mashine to ESXi using tool plink.exe.
On ESXi I create shell script file with these parameters:
--backup-vms=Windows Server 2012 R2!Windows Server 2012 R2_1.vmdk \
When I execute the script localy on ESXi everyting works fine, but when I try to execute script from plink.exe nothing is happening.
This is my plink execution command:
plink.exe -ssh root@ip_of_esxi -pw root_passwors -v -batch (/vmfs/volumes/datastore1/xsibackup/commands.sh)
Any other commands work fine, except xsibackup.
My ESXi is free 6.5.
Last edited by nikesg (2018-01-19 14:32:15)
What do you mean by "nothing is happening". Have you turned on debuging?, how are you parsing the password, manually?
Come on!, "everything else is working except XSIBackup", what is everything else?. XSIBackup is a bash script, so it will behave as any other bash script, there's nothing that prevents executing it remotely, just turn on debuging and narrow the cause down.
Last edited by roberto (2018-01-21 22:05:14)
I think I know what nikesg is talking about as I am having the same issue. I have already sent an email to support and have not received a reply yet.
My issue is the same if I use plink or another Linux servers crontab. Either way I can ssh to the host call a backup_job.sh manually and it works fine. If I try to use cron or schedule plink the job will not run. it looks as if when the ssh session closes it kills the sh process that was going to do the backup. see below for details.
Here is the command from the command line. This command works.
ssh -i /mykey_id_rsa -t -p22 firstname.lastname@example.org "ash /vmfs/volumes/54c962e9-e1b7442c-0af2-2c0356f9fa57/xsi-dir/remote_job.sh"
Here is the crontab entry. It will not work. I change the 43 and 13 to the current time to test it. I see that it connects to the host but the job does not run.
43 13 * * 7 ssh -i /mykey_id_rsa -t -p22 email@example.com "ash /vmfs/volumes/54c962e9-e1b7442c-0af2-2c0356f9fa57/xsi-dir/remote_job.sh"
Here is the ssh login log when it fails.
2018-01-21T18:43:00Z sshd: /etc/ssh/sshd_config line 7: Deprecated option UsePrivilegeSeparation
2018-01-21T18:43:00Z sshd: /etc/ssh/sshd_config line 15: Unsupported option PrintLastLog
2018-01-21T18:43:00Z sshd: Connection from 10.1.0.130 port 41762
2018-01-21T18:43:01Z sshd: Accepted publickey for root from 10.1.0.130 port 41762 ssh2: RSA SHA256:uGE4okWP/UWfSvaMObOMhNHCuXNCVHqWLmULIPyqpW8
2018-01-21T18:43:01Z sshd: pam_unix(sshd:session): session opened for user root by (uid=0)
2018-01-21T18:43:01Z sshd: User 'root' running command 'ash /vmfs/volumes/54c962e9-e1b7442c-0af2-2c0356f9fa57/xsi-dir/remote_job.sh'
2018-01-21T18:43:01Z sshd: Session opened for 'root' on /dev/char/pty/t2
2018-01-21T18:44:31Z sshd: Session closed for 'root' on /dev/char/pty/t2
2018-01-21T18:44:31Z sshd: Received disconnect from 10.1.0.130 port 41762:11: disconnected by user
2018-01-21T18:44:31Z sshd: Disconnected from user root 10.1.0.130 port 41762
2018-01-21T18:44:31Z sshd: pam_unix(sshd:session): session closed for user root
Here is the processes when it runs from the command line remotely. So if I run it from a command line remotely it will work. If I run it from a cron job remotely it will not work.
[root@host-2:~] pgrep -fl remote_job.sh
11404925 ash /vmfs/volumes/54c962e9-e1b7442c-0af2-2c0356f9fa57/xsi-dir/remote_job.sh
11404924 sh -c /vmfs/volumes/54c962e9-e1b7442c-0af2-2c0356f9fa57/xsi-dir/remote_job.sh
My thoughts are that is something to do with the ssh session sending a signal to kill the process when the ssh session ends. I tried to use nohup with out success. i see that in esxi the root cron has a 2>&1 at the end to direct the output but I cant seem to get it to work remotely
If I get this to work the way I need it to we will be looking for an enterprise license as we have 6 sites with 3-40 hosts per site. I need to be able to manage the backups from a central location with out only 1 job running at a time as there would not be enough time in our backup window to backup all of our VMs.
We offer the same support quality regardless of future aquisitions.
As stated, XSIBackup is a bash script, it doesn't close or kill anything selectively. We cannot offer support for any Linux distro, although it should simply work, just as long as you meet some minimun requirements.
You should probably increase the level of debuging, you may find out that you aren't able to run your job cause KEX is failing. OpenSSH has made some changes to KEX priorities lately, so you may need to tweak your SSH command or config file.
At least on the Linux side I am able to do this from cron by preceding the ssh command with nohup and using -tt
nohup ssh -tt root@server_ip '/vmfs/volumes/backup/XSI/backup-daily.sh'
I don't know if there is anything equivalent in Windows and plink.exe. You might consider the Linux subsystem in Win 10????
I think I have a solution for this.
I had to create a new PUTTY session using the GUI and set the following options:
Session: Set your host Name, Port, Connection type
Connection\Data: Set your Auto-login username to root
Connection\SSH: Set the Remote command for your backup job or script file (/vmfs/volumes/osdata/xsi-dir/backupvm.sh)
Go back to the 'Session' settings and save the session as something easy (xsibackup), etc.
Now, when using PLINK, connect to the session instead of the server and add your password if you want to automate it.
PLINK <sessionName> -pw <password> -v -batch
Last edited by rchkb (2018-02-27 18:25:36)
Another approach which is more secure is to take your RSA key from the XSIBackup installation folder and convert it to Putty .ppk format by using any of the free available programs. Then add it to your Putty profile in the SSH => Auth => Private key file for authentication input field by browsing for it.