Tag Info

Hot answers tagged

4

In such case I usually use heredoc to feed a script to remote shell. Not usable when script requires user input from stdin, though. ssh ${UserName}@server <<EOF1 ls -la ssh ${UserName}@server <<EOF2 ls -la EOF2 ls -la EOF1


4

Yes. It is possible. But if your script would be longer, I recommend to do this in more commands using ControlMaster, as Ansible does it, otherwise you will get lost in all the quotes, backslashes and stuff you can see in your post. scp script1.sh remote:/tmp/ ssh remote "bash /tmp/script.sh" and your script.sh can contain one more similar batch from ...


3

Rather than roll your own and have to cope with everything that can go wrong (host not responding, host stopping responding in the middle, user pressing Ctrl+C, error reporting, …), use one of the many existing tools to run a command on many machines over SSH. mussh -t 4 -H <(printf '%s\n' "${HOSTS[@]}") -c 'uname -a' pssh -t 4 -h <(printf '%s\n' ...


3

piping should be enough. Doing just: tar -cvj /path/to/your/files | ssh remote "cat > file.tar.bz2" (if you have set up passwordless log in using keys) Later on the other machine you can decompress the received file using tar -xvf path.tar.bz2 -C ./


2

One approach that would work is just appending to the end of the bashrc rather than syncing it. echo "PATH=\$PATH:~/bin" >> ~/.bashrc This will add ~/bin onto the PATH variable. In order to get this on a remote host you just need to call ssh first. You can use a for loop if you have lots of hosts. for host in host1 host2 host3;do ssh ...


2

I would suggest to use "-q -o "BatchMode=yes"" option as well as using a public key authentication... Also think about simple quoting the comand you'd like to run on the remote server to avoid any problem regarding a potential local interpretation of the given command. E.g : ssh -q -o "BatchMode=yes" user@server 'ls -al' This is a fairly common technique ...


2

You could use something like this to archive and copy through ssh: tar zcvf - stuff/ | ssh alex@localhost 'cat - > /tmp/stuff.tar.gz' Here you are creating a tar.gz archive but instead of saving it to some file you are using - which is standard output. The standard output - is then piped to ssh and from there on you cat from standard output cat - > ...


2

Traditionally, interactive password problems are solved by using the expect command which creates an intermediary pseudo-tty to talk to the process. Here's an alternative python version using the equivalent python-pexpect package. Create a python file run.py: import sys,pexpect (pw,cmd) = sys.argv[1:] child = pexpect.spawn(cmd) ...


2

A typical way to do this is to use the trap command to tell the shell script to ignore SIGINT (generated by Control-C), and then to re-enable SIGINT in a subshell just before your command is run. trap "" INT HOSTS=(MACHINE1 MACHINE2 MACHINE3 MACHINE4 MACHINE5) for i in "${HOSTS[@]}" do echo "$i" (trap - INT; ssh -q "$i" "uname -a") done


2

Sort of figured it out. Obviously something in the config file was stopping the server from starting. After implementing each file change one line at a time, finally found it was the ForwardAgent no line in the config that was causing problems. After some more digging, found that you could start the daemon direct instead of through the services to see if ...


2

The address specified in -L is used by the remote host (B). So it's no wonder that you actually have a tunnel between A and B by -L 5000:127.0.0.1:5000. When you are connecting to TCP port 5000 on A, the connection is forwarded to 127.0.0.1:5000 on B. On the other hand -R 5001:127.0.0.1:5001 would be fine because the address is resolved by the local host ...


1

It's hard to ask a question about linux distros in general, because some might... but, this is my experience with it, using primarily Ubuntu 14.04 server every day at work, setting up and configuring servers. There's not one that comes preinstalled (unless you select it at the last point of the install process - install software), but the most popular and ...


1

Seems like your solution on openssh mailing list seems to be quite bearable. Reposting also here: Match exec "ping -q -c 1 -t 1 %n | grep '192\.168\.'" StrictHostKeyChecking no UserKnownHostsFile /dev/null Source: http://lists.mindrot.org/pipermail/openssh-unix-dev/2015-August/034335.html


1

The issue is fixed now. seems to be an issue with Discourse SSH container configuration, In /etc/ssh/sshd_config PermitRootLogin without-password I've changed it to PermitRootLogin yes #PermitRootLogin without-password That fixed the issue.


1

Where should I store the user's cell phone number? And how should it be retrieved by the PAM module? This is entirely your design decision. Some PAM modules store information in local files in /etc, like pam_access or the google authenticator module. Other modules may contact a remote server, like the radius authentication module. A scalable solution ...


1

You are correct, it is your quotation marks. You are nesting single quotes without escaping. Try this: -e "sshpass -p P4ssw0rd ssh USAER@123.456.789.10 'cat /opt/logs/exaple.log | grep \'any problem\''" \



Only top voted, non community-wiki answers of a minimum length are eligible