Questions tagged [sshpass]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
39 views

sshpass No such file or directory

need add string to file on remote ssh server without prompting sudo password myuser=testuser $ sshpass -p "$mypass" ssh -t -o StrictHostKeycheking=no $myuser@$myhost "echo $mypass | ...
1 vote
2 answers
65 views

Using sshpass with rsync to accept a fingerprint

I'm using rsync to copy a file to a device: sshpass -p <password> rsync -avzP <file> <user>@<IP address>:<folder> This has worked fine in the past but I was trying to ...
  • 137
1 vote
1 answer
28 views

Saving the output of find to a variable in a remote server

# Declare the array declare -a LC_lines # Read the lines of the file into the array readarray -t LC_lines < unique_running_jobs_directory.log sshpass -p password ssh -n dummy@dummydomain.xx.yy.zz ...
0 votes
0 answers
154 views

How to download root user owned files via scp or rsync as a sudo user?

How to download the file which requires root permission from a remote server (via scp or rsync) as a sudo-user (non-interactive way)? Note that this sudo-user is not configured to not require the ...
0 votes
0 answers
173 views

sshpass Doesn't Display Command Output

OS: Debian 12 (Bookworm) fresh install on Asus 900A (i386) Command: sshpass -e sudo apt-get update The above command completes successfully, but without adding the -v switch to sshpass, does not ...
-1 votes
1 answer
283 views

Non-interactive way to connect via SSH (possible options)

I am trying to create a generic bash script to connect to the remote server via SSH using a non-interactive approach (using sshpass). All I need to know is the possible way to connect via SSH. So far, ...
1 vote
2 answers
2k views

Rocky 8.5 - Alternate repo for sshpass, removed from EPEL

BACKGROUND: I am developing a Kickstart file to install Rocky (8.5), and I have included EPEL as a repo in order to install Ansible. Yesterday, when trying to install from my Kickstart file, I ...
3 votes
1 answer
4k views

"ssh" works but "sshpass" doesn't - how is this possible?

I configured key pairs for SSH connection. It works but of course asks for the passphrase. ssh user1@10.7.175.143 So now I try to login with sshpass which I have installed. I tried with -p property ...
  • 198
2 votes
2 answers
600 views

Using sshpass in Cygwin, ssh stills prompts for password

According to this RedHat SSH password automation guide I'm following the Example 4: GPG one, and following the steps in that guide I create my pass_file using my own passphrase. Then, I got this: gpg -...
0 votes
2 answers
783 views

sshpass splitting the password as two strings seperated by the character "&" in password

I have a password variable PASS whose value is abc123&zxcv456 When I try to do SSH in jenkins using the password variable like below sshpass -p ${PASS} ssh -o StrictHostKeyChecking=no admin@100....
  • 11
2 votes
1 answer
1k views

SSH Tunnel with automatic reconnect and password auth in Docker container

I want to forward a Socks5 proxy using SSH with password authentication inside a Docker container. YES, I know that SSH keys would be better. But since it's not my own server, I'm not able to use keys,...
  • 299
-1 votes
1 answer
648 views

sshpass with sftp not working from crontab?

I have a ssh script (for testing purpose) that I can run successfully from cmd: #!/bin/bash /usr/bin/sshpass -p 'password' /usr/bin/sftp user@host:/out/test/ <<< $'put -r /data/test/*' A ./...
3 votes
1 answer
264 views

sshpass through regular ssh client

I am using an application that uses /usr/bin/ssh and requires passwordless authentication. Meanwhile I want to use this with a server that requires both publickey and password authentication at the ...
-1 votes
1 answer
602 views

Copying key to /root/.ssh/authorized_keys

I'm trying to copy a file (contains keys) to remote machine using below script. But the below error /root/.ssh/authorized_keys: Permission denied #!/bin/bash for i in `cat hosts` do cat team.keys | ...
1 vote
1 answer
292 views

In Shell Script SSH connection is working only for first line data in CSV file and command failing for remaining servers

My target is to just validate the login is successful for list of servers in CSV file. For SSH Password, Userid and IP address, I am passing these values via CSV. And want to capture the result of SSH ...
0 votes
2 answers
286 views

sshpass Solaris one liner passing a command

I am trying to pass one liner sshpass command to Solaris box but won't work. those are the options I tried: sshpass -p "passw" ssh "root@135.102.22.0" -o StrictHostKeyChecking=no `...
  • 125
1 vote
0 answers
723 views

Passing multiple passwords for SSHPASS in environment variables

Hope everyone is safe and healthy. I am facing an issue in introducing multiple SSHPASS passwords in environment variables (/etc/profiles) I am trying to SSH (using SSHPASS) to two different servers ...
  • 11
0 votes
2 answers
203 views

Login to ssh session and afterwards automatically look for and access existing screen session?

I would like to connect to a server using ssh and after logging in I would like to automatically execute screen -R My script looks as follows: sshpass -p password ssh -t name@server.cheese 'screen -R;...
  • 171
1 vote
1 answer
240 views

zsh completion for sshpass

I am using sshpass command like this: sshpass -p 'my_password' ssh user@server The full syntax, according to the man page is sshpass [-ffilename|-dnum|-ppassword|-e] [options] command arguments At ...
2 votes
2 answers
3k views

sshpass with ssh -J jump host

I have a script with a couple of ssh commands that use a jump host. I would like to enter the jump and target server passwords each time and tried to use sshpass sadly "nesting" sshpass does ...
  • 173
0 votes
1 answer
238 views

How can I run sshpass command with the remote environment, taking the source ~/.bashrc effect

For example, I run a command: sshpass -p passwd ssh dennis@ip python xx.py But, in this way, this command is running without the environment variables, which is set in /home/dennis/.bashrc. e.g.: ...
  • 111
1 vote
2 answers
7k views

sshpass alternative in linux shell/bash code

These are standard sshpass commands to read password from file or as argument. user@linux:~$ sshpass -f pwd.txt ssh admin@server admin@server:~$ user@linux:~$ sshpass -p P@55 ssh admin@server admin@...
user avatar
1 vote
1 answer
708 views

How to keep sshpass process in the background?

sshpass -p '1234567*' ssh -L 1080:192.168.0.1:2222 admin@gateway.com -p 4422 -f -C -N The above code works on macOS (creating a 1080 tunnel to 192.168.0.1:2222 via gateway.com:4422 with username ...
  • 151
0 votes
0 answers
697 views

How to run script with nohup through sshpass

I want to pass a local script generated on the fly and it will trigger another script on my remote machine to running some commands for a long period of time. this is the command I have tried: cat &...
  • 337
1 vote
1 answer
2k views

Bash script exit on command failure (sshpass)

I need to perform an operation on a list of server, through SSH. I am using sshpass, and that operation might fail, however it's supposed to happen a few time, and the script should still continue. #...
  • 211
3 votes
0 answers
2k views

sshpass doesn't work with some servers?

Using sshpass in bash script. I am connecting to the server, send the command df -h and save the output in a txt file. It works fine with about 10 servers. I found it doesn't work with some other ...
  • 31
-1 votes
1 answer
280 views

how to enable root ssh public key login with no root account and sshpass and sudo?

I have created an azure vm server which is ubuntu 1804 and I need to enable root ssh public key login with it. Azure do not want me to enable root ssh public key login when the server is created, so I ...
0 votes
1 answer
691 views

Output remote hostname in sshpass session

I have created a shell script to connect to a list of servers using sshpass and run a list of about 30 commands. An extract of the script is below. The script will wget a new config file, but then I ...
  • 3
0 votes
1 answer
594 views

brew is not found when I sshpass to the server

brew is installed on the server but when I sshpass to the server, it throws bash: brew: command not found and same is happening for ideviceinstaller bash: ideviceinstaller: command not found This is ...
  • 1
-1 votes
1 answer
204 views

plink from one server to another server sshpass

i am trying to run a command "df -kh" in linux server(192.168.82.11) from plink application via intermediate linux server(192.168.82.10) like below. But plink command not running, it hangs. As i dont ...
0 votes
1 answer
184 views

run command in script after an ssh

In my script I need to access a remote server using ssh. On the remote I want to gather some data from log files. I have my script set up and the code works, but my problem is when I run the script it ...
  • 9
2 votes
1 answer
2k views

How to safely pass password to a remote server to execute sudo commands

I have a very long bash script, at the end of it is a command to execute sudo commands on a remote server: 10 hours of local processing … ssh user@ip "sudo ls" I have set up ssh keys to connect to ...
  • 131
2 votes
1 answer
2k views

Stop CTRL+C Exiting Local Script Which is Running tcpdump in Remote Machine

I have setup a simple script like the below: sshpass -p $password ssh -T $username@$ip_address -p 30007 <<- EOF > $save_file.pcap sh tcpdump -i eth5.1 -s 0 -n -v -U -w - EOF sed -i '...
  • 23
0 votes
1 answer
2k views

How to Pass Multiple Commands to Remote Device via SSHPass [duplicate]

I'm trying to setup a method in which I can run remote tcpdumps on some of my devices, and save the file to my local machine for analysis (I don't want to save the file on the remote device and then ...
  • 23
2 votes
1 answer
2k views

sshpass in .ssh/config?

When running the command: ssh minix.p what I really want run is: sshpass -f ~/.ssh/minix-password ssh minix.p Is there any way I can do that? Background I want to use sshfs and similar tools, so ...
  • 32.3k
0 votes
1 answer
357 views

Executables specified with absolute path not found when using sshpass

Try as I might, I am unable to execute the lpstat and lp commands of CUPS remotely using sshpass in my script. I am able to execute all of the lines involving these commands when using an interactive ...
6 votes
2 answers
24k views

Multiple commands in sshpass [closed]

Is there a way to use the multiple commands in sshpass, I tried with difference combinations but it throws error. $ sudo sshpass -p $password ssh -t -oStrictHostKeyChecking=no $username@$ipaddress &...
  • 191
2 votes
0 answers
327 views

Can't set title with gnome-terminal [duplicate]

I'm using Centos 7. When I sshpass to my remote login server, I need to specify the title to every terminal I open through gnome-terminal. I tried following approach from the link suggested by @...
  • 43
1 vote
2 answers
3k views

SSH remote - display echo on local terminal

The following is a part of my script where I want to echo some text to the local terminal if the condition fails in ssh. /usr/bin/sshpass -p $PASSWORD /usr/bin/ssh -t -o "StrictHostKeyChecking no" ...
  • 8,837
0 votes
1 answer
454 views

unix throws error "sh: mntroot: not found" when doing sshpass with @host command, how to solve this?

My requirement : i want to pass some commands with sshpass command. ex 1: sshpass -p 'sshpass' ssh -oKexAlgorithms******* user@host touch /mnt/us/pass above sshpass example works perfectly. ex 2: ...
  • 133
1 vote
1 answer
194 views

Tracking child processes sequentially

I'm running few commands on a remote server, by sshpass. gnome-terminal --maximize --tab --title='aTask' -e "sshpass -p "afsd@#$5u89f" ssh root@192.168.0.125 'command1 && command2'" \ ...
  • 43
5 votes
1 answer
7k views

Execute multiple command through SSH using sudo

#!/bin/bash while IFS="," read -r f1 f2 do username="testuser" SSHPASS='abcde' sshpass -e ssh -t "$username@$f1" "sudo su - root -c 'yum -y install wget'"< /dev/null ; done < Input.txt Now ...
  • 51
1 vote
1 answer
4k views

Mount sshfs as non-root hangs forever

I made a sshfs mount point in my fstab, using sshpass to send the password (I need to do this because key authentification is not available on the remote server). Mounting the folder logged as root ...
  • 41
5 votes
2 answers
12k views

sshpass not functioning in alpine linux

When I install sshpass on alpine linux it will install and the doc will show up if you run it without arguments, but using any argument (valid or invalid) returns sshpass: Failed to run command: No ...
  • 281
-1 votes
1 answer
1k views

SSHPASS rsync scp -r copying few files worked later not working

rsync: link_stat "/home/user/file.txt" failed: No such file or directory (2) sshpass -e ssh -oBatchMode=no $user@$ip.$remotehost "rsync -v -e ssh file.txt /home/user/$folder/ && cd /home/user/...
1 vote
0 answers
740 views

Use sshpass to scp files from two remote hosts

I have the following problem. I have sshpass installed on Server A. I have files on Server B that I need to copy to Server C. (Servers B and C don't have sshpass installed, and are in another ...
  • 11
1 vote
0 answers
2k views

automount sshfs with autofs and sshpass

I want to mount partitions from a remote NAS that doesn't support login with a certificate. I created or edited the following files: /etc/ssh/sshpass.232 with ssh password /etc/ssh/sshpass.232.sh ...
2 votes
2 answers
468 views

How can I pass two files through ssh?

I have a bash script that will execute a script of my choosing against a server over ssh. My problem is that I also want to use an input file with common variables so I don't have to change them in ...
  • 35.1k
1 vote
4 answers
8k views

ssh remote file execution is not working

I have a bash script test.sh that contains the following commands #!/bin/bash PASSWORD="" USERNAME="" REM_HOSTNAME='localhost' FILES_TO_COPY="remote_exec.sh" function scptmp { exec sshpass -p $...
  • 215
1 vote
0 answers
2k views

Failed to install sshpass linux Ubuntu

After sudo apt-get update I tried to install sshpass library with sudo apt-get install sshpass But I get this error message: Reading package lists... Done Building dependency tree Reading ...