1
vote
2answers
156 views

Shell Script - how to scp into remote server and download files and protect password

I have a remote server that I need to download Apache logs from. I can manually scp into the server and get the files, but I'd like to put this in crontab. The only way to automate it is to include ...
2
votes
0answers
40 views

Remote script cleaning up

I run a remote script using ssh: local script: local_command ssh -p 222 user@server 'sh -s' < ./remote_run.sh remote script: some_command & sleep 10000 trap 'echo exiting' SIGINT SIGTERM ...
3
votes
2answers
126 views

Variable assigned inside ssh command doesn't return proper value

I'm executing the below command in the ssh part of my script. The command is meant to cut the file size from ls option and storing it to a variable. Then print the variable: echo "Enter srouce file"; ...
0
votes
1answer
69 views

How do I log out/disconnect from SSH after starting a process with output to keep it running? [duplicate]

I ran a script from the command line today (php, not sure that matters) which has output I wanted to watch but I had to go home before it finished and I couldn't figure out how to exit without killing ...
2
votes
1answer
76 views

SSH Command behaves differently in Expect Script

I'm using this command on Server1 ~# ssh root@Server2 /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys to append the contents of Server2's id_rsa.pub to the authorized_keys of Server1. It ...
0
votes
1answer
102 views

How do you keep the password hidden when invoked during the su command?

This is the first time it has happened to me where I am using the su command and it actually displays the password on the terminal and doesn't stay hidden. Here is my code snippet: sshpass -p ...
2
votes
1answer
362 views

Change IP remotely over ssh

I am using CentOS. I have a management server which has password-less ssh access to four other servers. I don't have physical access to these servers. In other words, I have to make all ...
3
votes
3answers
105 views

How can I automatically log in to a list of servers to prevent account lockout?

I have started a new contract, and need to have an active account on almost 200 servers. Security has accounts lock after 30 days of inactivity, as well as if you do not log in within 1 hour of ...
0
votes
1answer
523 views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
-2
votes
1answer
104 views

automatic capturing top output by cronjob CENTOS 6.5 x86_64

I have this command: top -n 14400 -a -b -d 1 > /toplogfile.txt I want to make a script which is run by cron every day to capture top output, and if it is possible gzip the output file after the ...
19
votes
5answers
8k views

Using while loop to ssh to multiple servers

I have a file servers.txt, with list of servers: server1.mydomain.com server2.mydomain.com server3.mydomain.com when I read the file line by line with while and echo each line, all works as ...
9
votes
3answers
1k views

Advice for managing SSH keys

What is the best practice you have found for managing lots of SSH keypairs? I use SSH to connect to several systems, both at home and at work. I currently have a fairly small, manageable collection ...
1
vote
3answers
193 views

Launching shell script from SSH and disconnect

I have a script which I run from SSH that launches several processes which I would like to keep open when I disconnect from my session. Is that feasible? Launching the script in background is not a ...
2
votes
1answer
2k views

Ssh to a box, run a command, output data to a file, then move on to the next IP adress [duplicate]

I want to run a script from my Jump server, have it SSH to a server, then run a command (like rm <file>, top or ls -lsa) then take that output and put it in to a file on my Jump server then move ...
0
votes
1answer
352 views

Counting files on a remote server with ssh and an expect script

Below is my script to take count for files which are present in remote server. But it is not working. Please help me. #!/usr/bin/expect spawn ssh sduser@172.0.0.2 expect "123" send "123" interact ...
1
vote
1answer
260 views

Why ssh -nq -t can't see my environment variable?

I am executing a command on remote machine with -t flag ( to prevent the command from 'blocking' ) the prompt (somehow it works that way). So I am using ssh -nq -t root@ip but with this, the script ...
4
votes
4answers
5k views

Automated ssh-keygen without passphrase, how?

I would like to make an automated script that calls ssh-keygen and creates some pub/private keypairs that I will use later on. In principle everything works fine with.... ssh-keygen -b 2048 -t rsa -f ...
2
votes
1answer
717 views

permission denied executing script over ssh

When a web page is loaded on server A i want it to run a script on server B. I can do this with a series of commands from server A by logging into server B and executing the script, but it needs to be ...
2
votes
1answer
1k views

Script to get file from SFTP and run it

We have 5 servers running our code: A, B , C, D and E. From a local machine, we sftp the file to A. Then ssh id@A su - applicationname sftp id@A get <file> bye tar -xzf <file> logout ...
4
votes
3answers
3k views

Execute remote script with local parameter value

How can I automatize this task? 1) You are at A. 2) You ssh into B. 3) You run a script at B, that needs a parameter known at A. First, I thought perhaps I could send the value when I opened the ...
0
votes
2answers
228 views

Autentification on SSH connection in OneLine [duplicate]

Possible Duplicate: Shell Script for logging into a ssh server I need to connect via SSH to a remote server, however I must do this with out interactive mode and with out use Public keys ...
3
votes
4answers
1k views

passing passwords to a script

I want to scp a file to a remote host, and from there, run a command on the file, and exit the remote session. If I write a usual script, call scp and then ssh, I am prompted to enter two passwords. ...
14
votes
7answers
30k views

Execute remote commands, completely detaching from the ssh connection

I have 2 computers, localpc and remoteserver. I need localpc to execute some commands on remoteserver. One of the things it needs to do is start a backup script that runs for a number of hours. I ...
5
votes
3answers
1k views

Keep running a script via ssh

ssh can use to run remote commands. ssh me@server.com 'long-script.sh' I run a long script that will take a lot of time, but I want to close my computer and keep running the script in the remote ...
0
votes
2answers
280 views

Creating SSH Terminal Wrapper

I'm new to scripting, but somewhat familiar with Linux. I am actually using this on a Fedora16 build, with Gnome3 and gnome-terminal... fyi. I flip through all sorts of ssh terminals all day long ...
0
votes
3answers
482 views

wrapper command for sshd_config?

Is there a command to set settings in sshd_config, instead of manually editing the file? I would prefer it to do this way, because it's easier to automate. Otherwise I'd have to grep config with my ...
7
votes
8answers
7k views

Automatically run commands over SSH on many servers

There is a list of IP addresses in a .txt file, ex.: 1.1.1.1 2.2.2.2 3.3.3.3 Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is ...
12
votes
3answers
6k views

Answer yes in a bash script

I'm trying to do a git clone trough a bash script, but the first time that I run the script and the server is not known yet the script fails. I have something like this: yes | git clone ...
3
votes
1answer
612 views

Make a failed SSH forward a fatal error

I have a script which connects to a remote host to replicate some files via SSH. I must connect to an rsync daemon listening on port 873. To accomplish this I have a ssh configuration like this. ...
7
votes
6answers
11k views

How to run commands in batch mode over ssh?

How can I run commands in batch mode over ssh? That is, what is the ssh command's equivalent of sftp -b <filename> <hostname>? I have a set of commands which I wish to run across a set of ...
3
votes
8answers
714 views

Write a remote managing script

I need to be able to locally run a script that will connect to various servers and run commands on them. What is the best way to accomplish this?