0
votes
7answers
146 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
27 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
70 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
95 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
63 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
78 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
57 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
53 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
80 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
87 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 ...
1
vote
0answers
102 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
80 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
179 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
129 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
658 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 ...
0
votes
3answers
186 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
157 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 ...
0
votes
2answers
474 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
83 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
290 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
127 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
121 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
169 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
118 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
241 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
910 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
144 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
157 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
60 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
99 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 ...
1
vote
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
91 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
87 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
309 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
488 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
812 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
67 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
127 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
223 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
117 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
864 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 ...
13
votes
6answers
4k 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
176 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
285 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 ...
1
vote
1answer
364 views

Using www-data through SSH

For development purposes I'm using www-data (on an ubuntu 11.10 server) to ssh in and fire git commands and basic stuff against the webroot. I don't have things like command history, coloring, etc ...
3
votes
2answers
1k views

Script to run chown on all folders and setting the owner as the folder name minus the trailing /

Some numpty ran chown -R username. in the /home folder on our webserver thinking he was in the desired folder. Needless to say the server is throwing a lot of wobbelys. We have over 200 websites and ...
0
votes
1answer
2k views

Chrooted user does not start in his home directory and does not load his bash_profiles

If the users logs in, he starts in / of the chroot (Which is /var/jail on the real machine). I would like him to start in his home-dir. Also, he seems not to load any of his profile-files (.bash.rc ...
0
votes
1answer
163 views

Amazon Cloud Instance SSH prompt customization [duplicate]

Possible Duplicate: Bash prompt on Ubuntu - FQDN (\H) same as hostname (\h) Is it possible to customize ssh shell prompt to show domain name instead of ip e.g ubuntu@ip-xx-xxx-xx-xxx:~$ ...
1
vote
2answers
144 views

I've installed “dash” but still see “bash” when I login via SSH [closed]

I've configured my Raspberry Pi to use "dash" for default shell, as instructed here. I have Dropbear for SSH. When I login via SSH, I still see the "bash" console, and not "dash". How to change ...
1
vote
1answer
944 views

How do I correctly SSH port forward using LiveReload on Redhat?

Referencing this page: http://feedback.livereload.com/knowledgebase/articles/86280-if-you-edit-files-directly-on-your-server It says you can remotely port forward the LiveReload specific port of ...