0
votes
1answer
28 views

Unable to redirect STDOUT in a remote screen session via SSH

I would like to execute a long-running command via SSH/screen and have the output redirected to a file. I'm able to run the command fine (similar to this question), but the output never shows up. ...
0
votes
0answers
35 views

Non-interactive shell expand alias [migrated]

I'm having trouble getting aliases to expand on my hosting account when I run a command like: ssh user@server "bash -c \"alias\"" My .bashrc file is: echo .bashrc # .bashrc shopt -s ...
0
votes
1answer
15 views

Trouble using ssh-key gen specifying location and password

This is my code: ssh-keygen -t rsa -C "$APP" This works perfectly. However it then asks me to specify location and password. I was hoping I can automate this all in one go, however this command ...
33
votes
8answers
3k 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 ...
0
votes
2answers
68 views

Run Bash Script Another Server

I want to run command one by one, for change the names of the directories on the server. When I run script, directories renamed in server 1. But, directories are not found in server 2. What the ...
2
votes
4answers
113 views

Run local script over ssh

silent ssh is setup from server A to server B (and some 500 other servers) I have written a script on server A (shell and perl) that I want to execute via ssh on server B (and the other 500 servers). ...
0
votes
7answers
182 views

better way to loop through a list of servers

I regularly do things where I loop through a list of servers to take some action. For example: for s in `cat servers.txt` ; do echo; echo $s ssh $s 'do something' done I'm wondering (from a ...
0
votes
1answer
46 views

Bash function hangs while command run perfectly without function

Following function hangs : ssh() { local RESULTS; RESULTS=$(ssh $USERNAME@$SERVER $SSH_COMMAND1); echo $RESULTS; } ssh; while if i run following commands they work fine : ...
0
votes
3answers
106 views

Tail a file from ssh and mirror to a local file

To tail a file over ssh, I can use ssh -t remotebox "tail -f /var/log/remote.log" However, it is possible to sync the tail with a local file? So a file automatically mirror the update of the tail ...
0
votes
2answers
779 views

Script SSH to router and “enable” and run commands

I have a script that will ssh to a list of routers and run commands from commands.txt. I want to enable after I connect to the router through ssh before I execute the rest of my commands in ...
0
votes
1answer
122 views

change user after ssh and execute multiple commands

I have a simple shell script to login as a normal user, and this normal user has a shell ready to switch into a user that has sudo privileges. However, I can't get it to work: sshpass -p PASS ssh -t ...
1
vote
3answers
203 views

Execute command over SSH while logging live output

I'm trying to log the output of a remote ssh command. I'm current using ssh USER@IP | tee -a ~/random.log and then run the command I need to run on the remote server which then logs to random.log. ...
0
votes
0answers
67 views

SSH chroot solution for Mutt

We have an environment tailored for our users to log in via ssh and instead of gaining access directly to a shell, users have a script in place of a shell. The script simply launches Mutt on the ...
1
vote
1answer
61 views

How to programatically find default ssh key?

In most of my experience, by default, ssh will look in ~/.ssh/id_rsa(.pub) for the default key pair. Ocassionally I try to write scripts to take advantage of this default key location, but I end up ...
1
vote
1answer
117 views

Bash script for updating multiple servers not accepting RSA keys

In my environment I manage about 10 Linux servers that require regular package updates. I have a script written to connect to each individually and run the update. Additionally, I have RSA keys ...
0
votes
3answers
99 views

Add an additional check (bash script) to the sshd server

Is it possible to run an additional script during the login process of the sshd daemon/server? I would like to run an additional command that uses the IP address and the username of the attempt. If ...
2
votes
0answers
140 views

Ssh issues on Google Compute Engine

I've just updated a few servers to the newer version of the gce stack, and I've started having some ssh issues that I'm not quite sure how to fix. I've already looked into issues with the firewall, ...
0
votes
1answer
98 views

Can a user be excluded from /etc/profile.d scripts?

I am having a problem using Rsync/SSH with a specific user for Amanda backups on a server. rsync -e 'ssh -i /var/lib/amanda/.ssh/id_rsa_amdump' -az otherserver:/dir/to/copy /copy/dir I have noticed ...
2
votes
1answer
332 views

Terminate remote process when backgrounded ssh session is terminated

So right now I have a bash script that runs a command on a remote machine using ssh. The machine running the bash script is a Linux machine and the remote machine is a Windows machine running cygwin. ...
2
votes
4answers
178 views

How to migrate ssh key to new CentOS server?

We have lots of scripts that run over ssh through saved (passwordless) key pairs. Both clients and servers are CentOS 6.x.I know that if you get a new client computer (where the scripts are run from), ...
3
votes
3answers
994 views

Log commands executed over ssh

I would like to log all commands executed over SSH. Say, ssh something@server.com COMMAND I want to log "COMMAND" on server.com I did search extensively but could not find anything. There is ...
1
vote
3answers
277 views

How to add SSH known host in a bash script?

I am creating a bash script to provision a new server that I can deploy a web application to. One thing I always have to do is as GitHub as a known host using ssh git@github.com. How can I automate ...
2
votes
2answers
199 views

executing .bash_profile alias via SSH

I would like to remotely execute a .bash_profile alias, but I cannot find the proper command. I tried: ssh user@host "bash -ic myalias" but it doesn't work I get: bash: cannot set terminal process ...
1
vote
3answers
878 views

Running ssh-agent from a shell script

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The ...
-10
votes
1answer
87 views

Stop server maintenance [closed]

I am ssh'ing into the remote CentOS server with Bash. I was trying to stop port 8080 and so I typed stop 8080 with "root" privileges. Now, the server is scheduled for maintenance in 8080 minutes as ...
1
vote
2answers
512 views

How can I make ssh wait until the command exits? [closed]

I have a script that looks like this: SERVER="RHT372 RHTl373 RHT374 RHTl375" case $1 in "stop") for SERVER in $SERVER do echo "================================================" echo ...
2
votes
2answers
139 views

Connecting to a port-knocking protected resource

Considering the excellent answers on the SF question "Preventing brute force attacks against SSH", I am considering configuring port knocking on a test server. I am debating how I will connect to this ...
2
votes
1answer
132 views

init script terminating with ssh session

We need to run pt-stalk on a handful of servers to keep an eye on mySQL, and I was sick of manually starting it every time the server rebooted. A little googling turned up an init script for pt-stalk, ...
2
votes
1answer
257 views

adding PATH in /etc/profile and ~/.bash_profile but not showing via SSH [duplicate]

on Centos 6.x, I am adding some path export PATH=$PATH:/some/path in both /etc/profile and ~/.bash_profile but if it's not effective when I login via SSH it only shows if I type source ...
1
vote
1answer
140 views

Shell script error on filename with spaces

I have a bash script that search for every static file located under my server root and stores a gzipped version next to each file. I got it from ...
-1
votes
1answer
288 views

SSH reverse tunnel through middleman server - how to connect in one step?

My question is basically how to turn my existing two steps into one step. I have a working SSH tunnel set up between two computers using a middleman server like this: ...
4
votes
3answers
1k views

Run a local script on a remote server using ssh with out having to worry about quotes

So I have been running local scripts fine on a remote server: ssh user@server "`cat local-script.sh`" However, today I have a script that has both single and double quotes in it. Which causes the ...
-1
votes
2answers
158 views

Cannot source .bashrc over SSH

Logging into my work station over SSH, I notice that none of my aliases work. Sure enough: $ alias $ source ~/.bashrc Could not open a connection to your authentication agent. So I googled the ...
1
vote
3answers
178 views

“while read line” returns early when calling ssh “mysql…”

I have a script that reads in data from mysql (the get_sql_results function below) I then read in each line, parsing individual columns with awk. Everything works fine except for the line that assigns ...
0
votes
2answers
61 views

Quitting Screens With Same Name With SSH [duplicate]

I have a server, with a few screens started. This is what shows when I use screen -ls: There are screens on: 12811.screen (Detached) 2061.screen (Detached) 7055.screen (Detached) ...
1
vote
2answers
101 views

Close/Quit All Screens with SSH

I have a lot of screens on my server. With screen -ls I get: There are screens on: 12858.test1 (Detached) 28210.test2 (Detached) 12494.moretesting3 (Detached) 31787.testingfour4 ...
2
votes
5answers
2k views

Executing script remotely with “curl | bash” feedback

I'm working on a platform that uses a lot such commands: ssh login@server.com 'curl http://some_server/script.sh | bash' This is really clean and handy to execute scripts remotely, however, I don't ...
0
votes
1answer
96 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 ...
3
votes
2answers
102 views

Get hostnames into ssh tab-completion (with minimal editing)

I know I could get a list of hostnames into bash tab-completion of ssh by adding them to /etc/hosts, but since they are on DHCP, it's kinda bad practice. Does anyone know another DHCP-aware way, that ...
0
votes
1answer
371 views

Error when using Chef on OS X: “bash: chef-solo: command not found”

I have chef installed on my local machine: Mac OS X 10.8.3 I also have chef installed on a remote server: Ubuntu 12.10 x64 Server On the local machine, when I try to execute a command using ssh ...
0
votes
2answers
742 views

Executing a remote MySQL query over SSH

I am trying to execute a MySQL query over ssh using the following command: ssh -p 2020 mysql@mysql1.local.mydomain.com "mysql --verbose --compress --secure-auth --database ops --execute \ 'INSERT ...
0
votes
1answer
1k views

Running a remote SQL query over SSH

I am attempting to execute a MySQL query on a remote server over ssh. Here is the command I have: ssh -p 2020 mysql@mysql1.local.mydomain.com 'mysql --compress --secure-auth --database operations ...
0
votes
2answers
73 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 ...
2
votes
2answers
149 views

ssh remote execution of multiple files

I've got two local files, one config.sh that contains variable definitions, another script.sh that contains a bash script. Locally, I can do: source config.sh; bash script.sh I'm looking for the ...
2
votes
3answers
238 views

Added line to bashrc, now bash is not responding

I added the following line to the end of my ~/.bashrc (This is on a Linode box) and logged out of my ssh session. source ~/.profile Now when I log in, the shell is unresponsive. I never get to the ...
0
votes
4answers
131 views

Linux utility to monitor for stupid / likely ill-advised commands

sudoing adds a little bit of a roadblock to doing potentially stupid and dangerous things in the Linux shell, but it is a meager deterrent to newer Linux users. Still, many users login as root or have ...
2
votes
1answer
1k views

Run multiple commands over SSH as sudo

I am trying to run commands as sudo over SSH, without success: ssh -t -p 2222 name@server /usr/bin/sudo << EOF chmod u-r /xy chmod +x /xy /xy sleep 5 ps aux | grep xy sleep 5 ...
15
votes
6answers
5k views

Can't log in via SSH to any accounts set to use /bin/bash as a default shell

I'm trying to install bash as the default shell on a ARM Linux running on an embedded device (Synology DS212+ NAS). But there's something really wrong, and I can't figure out what it is. Symptoms: ...
0
votes
0answers
194 views

Different result with same grep conditions via ssh

Like in the subject I got different result from the same grep command. The following command is run on a central server which query the other servers via ssh. ssh root@$domain "grep `date +%Y/%m/%d` ...
1
vote
2answers
323 views

Cannot log in to bash

I was trying to install ncurses on a virtual Debian server on VMware and somehow was unsuccessful. After logging out of the console, I realized that I could not log in anymore. I cannot use tools such ...