Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
9 votes
7 answers
969 views

Check if multiple files exist on a remote server

I am writing a script that locates a special type of file on my system and i want to check if those files are also present on a remote machine. So to test a single file I use: ssh -T user@host [[ -f /...
Nunkuat's user avatar
  • 193
0 votes
0 answers
49 views

SSH Agent Scope Issue with i3 and Detached Process

I have an issue with scope of ssh-initialization. I have following script for ssh-init.sh: #!/bin/zsh check-ssh-agent() { [ -S "$SSH_AUTH_SOCK" ] && { ssh-add -l >& /dev/...
Eugene Shtoka's user avatar
0 votes
1 answer
61 views

Commenting out a line item in a text file that my bash .sh file refers to

I have an ssh .sh bash script file i'm running on a cron to check website status. The bash script (when ran) refers to a local txt file for a list of websites to check if they're down or up. ...
sven30's user avatar
  • 103
0 votes
1 answer
93 views

Evaluating exit code of pipe or fifo

So i have something along the lines of: set -eo pipefail ssh localhost "ls; exit 1" | cat > output I thought pipefail would prevent cat to write to ouput (because of the exit code from ...
PKSWE's user avatar
  • 103
0 votes
1 answer
185 views

How can root get access to SSH_TTY

I think that SSH_TTY is an environment variable set by ssh that holds the device node of the current virtual terminal; e.g. /dev/pts/0, /dev/pts/1 , etc. I know that when I'm logged in to an SSH ...
Seamus's user avatar
  • 3,782
0 votes
1 answer
118 views

Adding an account via SSH not working with openssl

I am trying to add a user account to my remote server (running on Ubuntu 22.04) via SSH using below script: #!/bin/bash protect="y" ssh -i ssh_key [email protected] <<END sudo deluser ...
dzboot02's user avatar
  • 103
1 vote
2 answers
214 views

Multiple ssh sessions with different users

I am writing a script that connects to multiple servers which uses 3 different users. #!/bin/ksh server1=("abc1" "abc2") server2=("abc3" "abc4") server3=("...
NecroCoder's user avatar
0 votes
2 answers
80 views

Testing for dir via ssh script - nothing happens

I usually run server scripts like this, with a here-document. But when I test if a directory exists, the script continues even though the test fails -- why? ssh $user@$ip /bin/bash <<SCRIPT if [...
Vinn's user avatar
  • 236
4 votes
3 answers
573 views

Two ssh output as awk input

I have two remote servers that I am trying to ssh and cat some files.. I want to input the output of the ssh to a awk command. This is what I have got ssh username@host1 “cat /tmp/test/*” ssh ...
NecroCoder's user avatar
0 votes
0 answers
84 views

How do I make a .bashrc shell function interactive?

eshark() { ssh root@$1 'tcpdump -i $2 port 5060 -vv -s0 -Uw - ' | sudo tshark --interface - --print -w $3.pcapng } When I run this, on a Linux machine, it says capturing on stdin whereas when I run ...
David Conway's user avatar
0 votes
2 answers
285 views

How to execute local script (which executes another local script) in remote machine

I've written some script which looks like the following main.sh ls ./os.sh os.sh cat /etc/os-release executing like ssh user@serverA "bash -s" < ./main.sh "hi" "bye" ...
Md. A. Apu's user avatar
0 votes
0 answers
845 views

How to use heredoc inside my ssh command

I have a bash script that connects to a remote machine via SSH and runs a series of commands. It seems that the heredoc within the outer script is not aligning properly, and I keep getting an error. -...
George Udosen's user avatar
0 votes
1 answer
533 views

How to make a script to forward commands to an SSH server?

I have a remote SSH server with several custom utilities for my work. However, there are times when I feel lazy and don't want to start a full SSH session just to execute a single command. This ...
JM0's user avatar
  • 241
0 votes
0 answers
200 views

Continue running on remote linux server in an conda environment

I am working in a conda environment and want to keep running after my disconnect. Normally, I use nohup for this purpose but is it possible to use nohup in a conda environment? nohup bash program.sh ...
heyula's user avatar
  • 19
1 vote
2 answers
3k views

How can I encrypt a password in a bash script?

I created a shell alias that runs a simple shell script. The script is shown below, it sshs into another Linux machine: #!/bin/bash sshpass -p 'P@ssw0rd' ssh username@hostname I would like to encrypt ...
OpenSourceSingh's user avatar

15 30 50 per page
1
2 3 4 5
26