PowerShell remote execution between two Linux servers - linux

I have the PowerShell scripts (.ps1) on my Centos server. I can successfully execute them locally, but don’t know how I can execute these scripts remotely from another Centos server.
I’ve tried to execute scripts after connecting over SSH and I’m getting errors
-command not found and -syntax error.
How to run PowerShell scripts on Linux remotely from another Linux box?

You can simply ssh to the PowerShell server and run your .ps1 scripts from the console like this: pwsh your_script.ps1

Here is the solution that I'm using:
ssh to the server: ssh user#server_name
navigate to the scripts directory
run pwsh script_name.ps1
I don't need to connect with PowerShell session and didn't do any configuration on PowerShell server. Hope it helps.

Related

Run and start denodo platform using Command Line Linux Remote Server without GUI

Run Denodo Platform sh files using Command Line Linux Remote Server.
Denodo Platform showing GUI to start Virtual DataPort, and I can only interact using Command Line only.
Is there a way to do this?
ssh into the server and go to your DENODO_HOME\bin folder
run this command there:
sh vqlserver_startup.sh

Executing a Shell Script on Remote Server :: Gives sqlplus: command not found

I have two servers Server A which has a shell script - 'Process_Backup.sh'.
I executed this script on server A - './Process_Backup.sh' and it executed fine. Basically this script connects to my oracle database on Server A and executes a procedure.
What I need to do is execute the script 'Process_Backup.sh' on server A from a different Server B.
I tried following command from Server B
ssh test#server1.xxx.com "cd Scripts/Shell; ./Process_Backup.sh"
But I am getting following error-
line 49: sqlplus: command not found
I have all the software installed on server A so not sure why am I getting this error. I am new to linux environment. I have gone through most of the question posted here but mine seems to be a different case.
Any help is appreciated
Oracle installs a file oraenv that sets some environment variables including the PATH where commands like sqlplus are. That file is included when you start your login shell, the commands to do that were probably created by the installer.
Use
ssh test#server1.xxx.com "source /path/to/oraenv; cd Scripts/Shell; ./Process_Backup.sh"
The file oraenv is probably somewhere below /usr/local.

Ssh command to Windows machine via bash script executed from Jenkins slave

I'm have some bash script (myscript.sh), one of logical steps is to run ssh command against Windows machine running open-ssh.
When I'm running the script (myscript.sh) from the shell everything works fine.
But when I am running same script from Jenkins (CentOS 7.3) it fails to retrieve content via ssh command: ssh root#windows-server hostname.
Please need your help.
The user running the jenkins process do probably not have the correct executable rights or group membership to do so.
Try
sudo -u "jenkinsuser" myscript.sh
If that fails you confirmed the issue.
Change the execute rights on your script or put the server process owner in the right group if this is the case.

Need to create Linux Users from Windows Machine using Batch file or Script . I am having ssh access to server.

I am having several Linux machine in my DC and i need to create one script in Windows Server which will create users on Linux machines. Please suggest.
If you have OpenSSH installed, just run this in your batch file once per linux client:
ssh root#linux-machine "adduser user_name --home /home/user_name"
Try to give a look to expect for Windows. Like the Unix version, you can remotely execute interactive commands.

How to create a script on windows which could run ssh command on a remote linux

I just want to create a auto script on windows which could do run some comand through ssh on a reomote linux.
I know it's easy to write script between linux(ssh client) and linux(ssh server).
But I do not know how to create a script on windows(ssh client) to remote connect to linux(ssh server)
If it's just some command lines you want to run then plink will be enough IMHO..
Goodluck.
Most popular languages have ssh libraries you can use, pick a language you are familiar with and then go library hunting.
I've used these with success:
C - libssh
.NET - SharpSSH
Python - Paramiko or Really Simple SSH or Fabric
use plink (get it from putty website) and a bat file format like this:
Plink.exe -ssh -pw %password5 %linuxuser%#%servver% /path/to/script/script.sh
Save em in same folder -> run your awesome masterpiece
One way is to install Cygwin and use a shell script to run ssh commands. You can launch this script by running sh.exe with arguments.
This way, you can do the job with the same Linux tools (sh and OpenSSH) that you are already familiar with.

Resources