I have a command something like ssh #*. When I execute this command in CMD it asks for password and upon entering the password, the connection will be successful. Please help me how can I handle this using os process sampler
I don't think you cannot handle this using ssh command as it doesn't allow providing the password as the parameter, it can only open an interactive shell which is not supported by the OS Process Sampler.
So instead of ssh client you need to consider the following alternatives:
Use key-based authentication so you won't have to provide the password
Use sshpass command
Use expect command
Switch to SSH Command sampler which allows execution of arbitrary commands over SSH channel, it supports both password and key-based authentication mechanisms, see How to Run External Commands and Programs Locally and Remotely from JMeter article for more details
Related
I have to make a jmeter script to connect putty and provide host name and click on connect which will open a cmd asking for user name and pwd.
Post which I have to type slrum command that is sinfo and it will retrieve data and finally an exit.
I have used plink to achieve the same.
In command parameter of os sampler,
/C
Plink -ssh user#host -pw password
I am able to successfully connect to putty and reach till pwd entry.
On typing slrum command in cmd manually,it is fetching result but the same sinfo when am trying to achieve through os process sampler it is giving error as sinfo command not found.
How to provide sinfo command from os process sampler to fetch correct output.
I don't know what is slrum or sinfo but I can think about some possible reasons:
You're logging into a session which doesn't call shell scripts to set the relevant PATH environment variable, i.e. this issue suggests to add /usr/local/bin to your PATH. I'm not sure how your installation looks like but you could try to use the full path like:
/usr/local/bin/sinfo
or whatever
You might want to pass -ssh key to your plink to force to use SSH protocol
And last but not the least, there is SSH Command plugin which don't require 3rd-party executables
Demo:
More information: How to Run External Commands and Programs Locally and Remotely from JMeter
Actually i need to record a script for the application which is connected via putty software.
For opening my application i need to follow below mentioned steps -
1. Click on Putty.exe icon.
2. Enter Hostname.
3. Select SSH as connection type.
4. click on Save.
4. Click on Open button.
I need to record these all steps using jmeter.
Please help me with feasibility and practicality ...
It is not something you can "record", if you need to execute a command on a remote machine it will make more sense to go for plink command from JMeter's OS Process Sampler
Download plink.exe and drop it somewhere to you local drive
Add OS Process Sampler to your Test Plan and configure it like:
Command to execute: cmd
First parameter: /c
Second parameter: `plink.exe username#hostname -pw password command
For example:
c:\jmeter\bin\plink.exe johndoe#localhost -pw secret cowsay "Jmeter is great"
The output will be available as normal Sample Result:
See How to Run External Commands and Programs Locally and Remotely from JMeter article for more details on kicking off 3rd-party programs from JMeter scripts.
You should add JMeter plugin SSH Protocol Support and SSH connect without putty.
SSH Sampler for Jakarta JMeter that executes commands (eg, iostat) over an SSH session, and returns the output
After you add the plugin Add -> Sampler -> SSH Command
And fill the authentication details and write your command in Command field (currently date)
I have to write a shell script which ssh to another server with other username without actually asking for a password from the user?
Due to constraints I cannot use key based authentication.
let,
Source Server -- abc.efg.com
Source UserName -- tom
Source Password -- tom123
Destination Server -- xyz.efc.com
Destination UserName -- bob
destination Password -- bob123
I have to place the bash script in source server.
Please let me know if something could be done using expect tool and/or sshpass.
It is okay for me to hardcode the password for destination server in the bash script but I cannot bear an interactive session, simply when I run he script, I want to see the destination server logged in with another username.
Thanks in Advance.
You want to use key-authentication http://ornellas.apanela.com/dokuwiki/pub:ssh_key_auth
Generate your keys ssh-keygen
Copy the keys to your new box ssh-copy-id -i ~/.ssh/id_rsa.pub me#otherhost.com
ssh to other host without password ssh me#otherhost.com
You can use expect to wrap ssh, but it's pretty hectic, and fails easily when there are network errors, so test it well or use a script specifically designed for wrapping ssh passwords. Key based authentication is better.
You can prevent interactive sessions by redirecting standard input from the null device, ie.
ssh me#destination destination-command < /dev/null
About placing the script in the source server, if the script you are running is local, rather than remote, then you can pass the script on standard input, rather than the command line:
cat bashscript.sh | ssh me#destination
You can install the sshpass program, which lets you write a script like
#!/bin/bash
sshpass -p bob123 ssh UserName#xyz.efc.com
The answer is that you can't as OpenSSH actively prevent headless password-based authentication. Use key-based authentication.
You may be able to fork the OpenSSH client code and patch it, but I think that is a bit excessive.
What I want to do is issuing one command that contains ftp commands that I want to execute. I want my command to contatin username, password and commands.
I only can use windows native ftp client program, and it seems it does not provide any help regarding this. What should I do?
did you read 'ftp /?' for example
Ftp -s:YouFileWithFtpCommands
I want to write one shell script like
command1
ssh vivek#remotehost
fire command on remote host
Now I have password in pass.txt . But when I change stdin with file. It is not reading password from file.
script.sh < password.txt
It is prompting for the password in place of reading password from the file.
What I am doing wrong ?
Second problem is that shell script don't shows the command fired. Is there a way , I can show fired command from it ?
Note :
I don't have key based access on remote system. I can only use password based login for ssh.
You can use ssh-agent or expect (the programing language) to do this.
OpenSSH ssh does not reads the password from stdin but from /dev/tty. That's why you have to use Expect or some other similar tool to automate it.
plink is another client, also available for Linux/Unix that accepts the password as a parameter on the command line... though that has some ugly security implications.
Okay, just to mention yet another option: sshpass is a tool developed for exactly the task of "fooling" regular openssh client to accept password non-interactively.