7
votes
4answers
624 views

How can I run arbitrarily complex command using sudo over ssh?

I have a system that I can only log in to under my username (myuser), but I need to run commands as other user (scriptuser). So far, I have come up with the following to run the commands I need: ssh ...
3
votes
2answers
98 views

Discrepancy in ssh-agent behavior

It seems like i'm having a bit of a discrepancy between the behavior of ssh-agent for two accounts I have configured. I wrote a simple monitoring script to check on the availability of some VMs we ...
1
vote
3answers
603 views

How can I suppress the “…this does not map back…” message when using SSH?

I am writing a script that attaches to several of our machines via SSH to check some usage stats. Each time I do: ssh -i ~/.ssh/ourkeyfile.pem user@host I get the typical message: Address ...
0
votes
1answer
95 views

Close a SSH Session when it suspend

I start a ssh session on a remote host and execute a script on the remote host. The Script is an update script that change the remote IP. Now my local bash script hanging on the line with this ...
0
votes
1answer
115 views

If I ssh to a remote computer and run a script, do I need to keep my connection for the script to finish executing?

I apologize if this question has been asked before, I wasn't able to find anything with my exact query. I have a rather lengthy script that needs to be run on a remote computer, and it takes about 3 ...
0
votes
2answers
70 views

get informations from x servers per ssh by bash script

I've server Master,SlaveA,SlaveB,SlaveC, and want to get eg. the space information from the server by executing one bash script on the master. How can I do that? --case-- 192.168.1.1 - Master ...
4
votes
4answers
213 views

Disabling ssh as root on Linux boxes and the challenges of writing scripts

It's a common suggestion from security-minded people to disable ssh as root on Linux boxes. My question is this: Let's say you normally write lots of scripts which ssh to a large number of Linux ...
1
vote
4answers
141 views

Stripping “extra spaces” in du -sk for bash script?

I am trying to use du -sk to get the size of two folders dirsize_temp=`du -sk /folder/path/here` and then an if statement to compare the sizes. The only issue is that when you run the command, it ...
1
vote
1answer
242 views

Scripting postgres synchronization--is this secure?

I have written a script to synchronize (recreating from scratch) a production database with a development database, and I wanted insight into potential security flaws/issues, the script is posted ...
1
vote
3answers
132 views

Why is ``head`` hanging and not terminating?

I have a shell script that has to find the newest file on a remote host. I have this bit: ssh -q $HOSTNAME -t ls -t -1 /path/to/somewhere/ | head -n 1 It prints the first line, then waits and ...
1
vote
2answers
937 views

CentOS: E-mail notification of failed ssh login attempts

Under CentOS, I need a script that will run every 10 minutes and e-mail me if there are any new failed ssh login attempts in /var/log/secure.
2
votes
2answers
2k views

Linux: ssh to host and use sudo to run a script, runs but part of script fails

I've searched high and low for an answer to this. I have keys setup so no password is needed for the ssh into remote host. I have sudo set up with that user so that I can run the needed commands as ...
0
votes
1answer
225 views

Running root script upon ssh'ing as a particular user, but not upon standard login

I would like to do the following : If I login as user ABC via the login screen, do nothing. However if I ssh as ABC, then I want to run a root script, without being prompted for roots password, and ...
0
votes
3answers
143 views

Using SSH to find access to a problematic script in logs of multiple domains

I run several (~20) sites on a Dreamhost VPS. Lately I max my memory allocation for the VPS and I want to find the problem. I would like to have an SSH script that will scan all the log files of all ...
3
votes
3answers
2k views

Why does TERM=xterm have to be set for my script to work correctly when remotely executed?

I'm attempting to automate the installation of a Debian server (debian 6.0 squeeze 64bit). Part of the installation requires the Sun JRE package to be installed. This package has a licence ...
0
votes
1answer
277 views

SSH in script without user interaction [duplicate]

Possible Duplicate: How to automate SSH login with password? Is there a way to call ssh in a bash script and automatically feed it the password for the account? e.g if i type ssh ...
0
votes
1answer
664 views

How to write a shell script for OS X to log in to a remote server via SSH and execute commands

This seems simple enough... I'm trying to write a script that I can just double click on in OS X. The script is to login via SSH to a remote server, run a git commit and exit. When I copy/paste my ...
1
vote
2answers
471 views

Keep script running after logout

I'm trying to run DiabloMiner, and keep it running after I logout. I try to use screen. So what I do is: login to the host, with -X switch. Like: ssh -X myhost run screen run my script, i.e. ...
2
votes
3answers
647 views

Pass your password to your SSH key via a script

I am writing a script that will allow me to retrieve a file from all of my servers at once. I have SSH keys in place in order to log into my servers. My SSH key however requires a password. The ...
13
votes
7answers
13k views

How do I run a local bash script on remote machines via ssh?

I am looking for a way to push configuration from one central machine to several remote machines without the need to install anything on the remote machines. The aim is to do something like you ...
1
vote
1answer
1k views

SSH to server with xargs

I have a pretty easy problem I'm trying to resolve here. I'm constantly running the (host) command on domains, to get their IPs, then (host) again on those IPs to get their PTRs, then I'm SSHing to ...
2
votes
3answers
2k views

Ubuntu/Debian/OpenSSH: Run (system) script on SSH login and/or logout

On Ubuntu, I'd like my OpenSSH server to start a script whenever a user logs in using SSH, ideally passing the host name or IP, as well as the user name. Additionally I'd like it to run a script, ...
1
vote
3answers
292 views

Script to be executed on ssh connect

There is a remote host, where I'd like to run a specific script every time I connect to it via ssh. Where should I put the file to be run automatically?
3
votes
3answers
4k views

bash script with permanent ssh connection

I use a bash script which runs /usr/bin/ssh -f -N -T -L8888:127.0.0.1:3306 serveradmin@34.324.234.23 However, when I run the bash script, it waits.. I see the connection coming up but the script ...
2
votes
4answers
2k views

How to execute a system-wide script upon any ssh login (with OpenSSH)?

Upon any ssh login/connection (anybody logging in through ssh), is there a way to have a script executed? Using OpenSSH server. The script should not be modifiable by any of the users, -- of course ...
1
vote
2answers
545 views

Multiple Users use Script to Access Remote Server via Passwordless SSH

I am currently setting up a linux box that is tied into Active Directory. This box will allow users to SSH into it with their AD username and password to gather information (Box A). The issue is I ...
2
votes
1answer
91 views

SSH authentication working unless ran from script?

I have set up my server to allow key/pair authentication by following instructions similar to what is found in this post. As far as I can tell that is working correctly. If I do the following, for ...
5
votes
4answers
20k views

How can i fully log all bash scripts actions?

I want to capture ALL the logs data, both with error messages, from my script output, and redirect them all to log file. I have script like below: #!/bin/bash ( echo " `date` : part 1 - start " ssh ...
0
votes
2answers
2k views

SSH not redirecting stdout to local terminal

I have the following relevant lines in a csh script: #!/bin/csh -xv set dvar = `date +"^%m\/%d\/%y"` set filedate = `date +%b%d%Y` set grepstring = "grep "\"$dvar\"" </home/user/log/logfile" set ...
1
vote
5answers
2k views

Retaining SSH session in bash script

I have a bash script which loops over a server list, runs a couple of remote commands via SSH, and writes the output of those commands to a local file. For every command I run on the remote server I ...
11
votes
4answers
15k views

How to run script via SSH that doesn't end when I close connection?

I need to run script, that takes long time to execute, or I just want it to run forever. I can't just SSH to my machine, because when I disconnect it stops running. Is there any way to run script ...