sshpass | Automate SSH logins when you 're forced to use password | Identity Management library
kandi X-RAY | sshpass Summary
kandi X-RAY | sshpass Summary
If you need to login to a server that, for whatever reason, has public key auth disabled, you can use this script to automate login via username and password. Your password will be stored in the appropriate keyring backend. (e.g. Keychain on Mac OS X).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- SSH to ssh
- Get a password from the service .
- Return the size of the terminal .
- Set the password for the given service .
sshpass Key Features
sshpass Examples and Code Snippets
Community Discussions
Trending Discussions on sshpass
QUESTION
For the following code:
...ANSWER
Answered 2022-Apr-08 at 15:14Here is a working example with bash for local testing. You can exchange the two bash commands by ssh / sudo:
QUESTION
I have an application that gets deployed from a docker image to a Kubernetes pod. Inside of my docker image I run the following command
...ANSWER
Answered 2022-Apr-04 at 06:16When the application gets deployed, out of my control, the user gets set to a non root user.
Inside the container, the user running java -jar /opt/app/app.jar
is root, because of USER root
.
Outside the container, on the host, a deployed application is usually (almost exclusively) never executed/accessed as root
.
But it should still make ssh request from within the container to a server:
- the openssh service is started
- the container /root/.ssh has the right public/private key
- the
~user/.ssh
folder, on the target server where the Docker application is running, has the authorized_keys with the public one in it.
But if the user does not exist inside the container, you need to create it on docker run
, as in here:
QUESTION
I am running the following code and unable to pass an argument in the command that I am executing on a remote Netapp cluster. Any insight will help
read -p "echo $'\n'
Enter the name for this cluster:" cluster
sshpass -p $pswd ssh $username@$hostname 'aggr show; aggr create -aggregate agg1_'$cluster' -disklist 1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.0.6,1.0.7 -simulate true'
...ANSWER
Answered 2022-Mar-24 at 02:30Finally tried below syntax to append the variable into the command that I need to execute..
sshpass -p $pswd ssh $username@$hostname "aggr show; aggr create -aggregate agg1_"$cluster" -disklist 1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.0.6,1.0.7 -simulate true"
QUESTION
I'm trying to export PGP sub keys to a remote machine using this script:
...ANSWER
Answered 2022-Mar-09 at 06:30The above script works perfectly. My issue was how I was passing the $REMOTE_PASS
variable to the script. For those who come across this, beware of special chars in the password. Encapsulate the pass in ""
(inverted commas) if necessary. For security purposes don't handle passwords like this if the password is highly secret.
In my case, the password is no longer usable after this initial connection.
QUESTION
I have a playbook that is launched from AWX with machine credentials, ie. with ssh_user_A
. In this playbook, i need to perform a couple of tasks with another SSH user, ie. ssh_user_B
.
In terms of credentials, I have:
- machine credentials for
ssh_user_A
that are OK, I can do whatever I need - a public/private keys couple for
ssh_user_B
:- the public key is present on the remote host in the
~ssh_user_B/.ssh/authorized_keys
file - if I test this public/private key with a temp machine credentials (not possible in final target) and a dummy playbook or an ad-hoc module call, it works I can do whatever I need
- the public key is present on the remote host in the
I change the SSH user in the playbook with these instructions:
...ANSWER
Answered 2022-Mar-02 at 08:54I've made a lot of tests and found the problem: by default, to connect to the target hosts, Ansible uses the smart
connection plugin. In my case, the smart
plugin leads to the use of the native OpenSSH.
Forcing manually the use of the paramiko
connection plugin solves the problem, everything is OK (paramiko is a Python implementation of OpenSSH). Just need to add the instruction connection: paramiko
at the needed level:
QUESTION
My playbook:
...ANSWER
Answered 2022-Feb-15 at 07:46My configuration file is wrong
vars add line:
ansible_connection: ansible.netcommon.network_cli
QUESTION
I am creating a script that uses different commands in different servers... To do it, I avoid to use tools like sshpass, and I try to do it by using paramiko (because with paramiko, I can handle exceptions and I can also exit the ssh session).
There are two machines that I must connect to, there are two different commands to use, etc.
The problem is, that I would like to not repeat the code I use twice, my code is something like:
...ANSWER
Answered 2022-Feb-08 at 09:33In general, the smallest element of code re-use is the function. So, make a function for creating the connection, for instance.
QUESTION
I have below Bash script where I am trying to Create functions for creating colors for output text in the script, I am trying to call these function into another one but somehow its not working.
I looked around and googled, but didn't get the anything concrete to my situation, Can someone please help we to get, what i am doing wrong?
Script:
...ANSWER
Answered 2022-Feb-03 at 13:32You still have to use command substitution to get the output of ok
et al. to use as an argument to printf
.
QUESTION
I have following script where i want to to print the command Variable SMB
into the RED colour within a bash function but that's not working.
Below is the Script:
Script:
...ANSWER
Answered 2022-Feb-02 at 18:52This should achieve what you expected :
QUESTION
i have a problem with my bash shell script. This is my code:
...ANSWER
Answered 2022-Feb-01 at 08:53#!/bin/bash/
while read -r line; do
echo -e "$line\n"
sshpass -p 'Password' ssh -o StrictHostKeyChecking=no root@$line -t \
"cd /exemple/ && sh restart-launcher.sh;exec \$SHELL -l"
sleep 5
done < Ip.txt
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sshpass
You can use sshpass like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page