Tagged Questions
2
votes
2answers
34 views
How to automate connecting to multiple network devices, running a command and saving the output to a file?
I have to run a command on around 1000 network devices and save the output to a file. In a file I have a list of all the network device names that have to be connected to using SSH. I then have to run ...
1
vote
2answers
70 views
Colorful ssh banner
I would like to colorize my ssh banner. I now I can perform it like so :
In /etc/profile I can put
echo -e "\e[1;31m Colorful text"
echo -e "\e[0m Reset"
But I have an ASCII art in the banner ...
3
votes
2answers
38 views
Specify script to run with SSH upon login
I would like to know if there is a way to specify what script to run (on the remote machine) at login. I'm logging into a Debian box with key-pair authentiation (no password needed). The script ...
1
vote
0answers
75 views
Using sshpass, return code (exit status) differs for reasons unknown using valid commands
There are a few things going on here but I think ultimately, either CLish or SSH is returning an exit code that is messing up my work flow.
I'm attempting to connect to a remote machine (CLish shell) ...
1
vote
1answer
123 views
How to put value of echo pipe netcat commands into variable [duplicate]
I have this command succession:
echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567
and let's say it return a string like, for example "Hello...bla".
(on the 89.196.167.2 i have made a server ...
1
vote
2answers
821 views
bash shell - ssh remote script capture output and exit code?
I wish to use shell to invoke a script on a remote server.
I would like to capture the output of that script (its logging messages) and the exit code it returns.
If I do this:
ssh user@server ...
4
votes
2answers
112 views
Is it possible to store ssh connection in bash script instead of $(ssh user@ip command) every time?
I think that the code that I already have is not very efficient as it has to connect each time to the same machine and execute a command. Code:
tmp=$(ssh -nq $USER@$IP "$COMMAND" 2>> $LOG)
...
3
votes
2answers
71 views
Any ideas to simplify the awkward rsync expression below?
Here is expression:
rsync -avz --progress -e "ssh -i /where/is/my/id_dsa" vivek@some.host:`ssh -i /where/is/my/id_dsa vivek@some.host "find /remote/source/dir -type f -name '*.sql' | sort -nr | head ...
3
votes
2answers
188 views
Run ssh login command without modifying remote .bashrc
We have a bunch of servers set up with set -o vi in their ~/.bashrc.
It would be nice to be able to ssh into these boxes and automagically run set -o emacs as a timesave.
I've seen a solution ...
0
votes
1answer
75 views
Can Bash Emacs shortcuts be enabled over SSH?
I find Bash keyboard shortcuts such as Ctrl-a (jump to start of line), Ctrl-k (cut text following caret), Ctrl-n/Ctrl-p (next/previous line in command history) immeasurably useful in day-to-day CLI ...
2
votes
3answers
916 views
Bash Auto-Completion feature for SSHing into Different Hosts
I have big list of servers which I normally ssh to all the time. Is there any way using bash or zsh so that I can keep the list of hostname and bash auto-completion goes through the file and gives me ...
7
votes
2answers
10k views
sudo over ssh: no tty present and no askpass program specified
I keep getting this error and have tried several ways discussed online to fix this and none are working for me. I have setup SSH keys so when I run 'ssh newton@host.com' it automatically logs me in, I ...
3
votes
2answers
516 views
How to fix bash or auto run /bin/bash on SSH login
When logging in as root at my server everything works fine, but when I log in as myusername the bash is not working correctly.
The line starts with:
$
instead of
myusername@myserver:~$
and all ...
6
votes
2answers
445 views
Why Bash unable to find command even if $PATH is specified properly?
I am specifying path to my command in the file /etc/profile:
export PATH=$PATH:/usr/app/cpn/bin
My command is located in:
$ which ydisplay
/usr/app/cpn/bin/ydisplay
So, when I performing "echo ...
5
votes
3answers
2k views
ssh input from text file
These two question is driving me crazy and I don't have good expertise of ssh. (but I suspect it is to do with redirection only)
The questions are,
You want to pass multiple lines of input from a ...
0
votes
1answer
173 views
How do I escape a dot character for an rsync command? [closed]
I'm trying to do...
ssh -av -e deploy@domain.com:/var/www/domain.com /Users/user/workspace/domain
But it's outputting this (I presume because of the period character):
OpenSSH_5.6p1, OpenSSL ...
1
vote
2answers
2k views
SSH + Sudo + Expect in Bash script: Run command with sudo in remote machine
I am trying to automate the deploy of some .deb packages with an script. I want to execute sudo dpkg -i $myDeb.deb in a list of remote machines I can access with ssh.
I've tried to automate the ...
2
votes
3answers
515 views
Run if statement on remote machine
I'm trying to run a set of commands on a remote machine, that includes an if statement. I'm using this to shutdown a list of kvm instances. The first line should be fine, but could be prettier, rest ...
4
votes
2answers
567 views
SSH LocalCommand on exit
In ~/.ssh/config you can use the LocalCommand directive to execute a local command whenever you connect to a remote machine via SSH. But how do I execute a command when I exit an SSH connection? It ...
0
votes
2answers
2k views
Checking if files exist in some remote folders with bash
I need to do a script to look in some folders and send an email if there are files in these folders.
I've tried to do something like this but I get errors with the command variable and print of the ...
1
vote
1answer
10k views
How do I execute a remote shell script over SSH and be prompted for passwords by commands that require it in that script?
I want to do something like this
ssh user@remote-domain.com ./remote_script.sh
Contents of remote_script.sh
#!/bin/bash
hg pull
This example is much simpler than what I am actually doing. I know ...
0
votes
2answers
370 views
How to direct bash network request through a socket5 proxy?
I know how to use http_proxy to redirect http request, but how to redirect the data with a socket5 proxy such as a SSH tunnel?
5
votes
1answer
572 views
playing a sound/notification in finch over ssh on my local machine
So I have finch, a command line chat client (think pidgin) running on a remote machine that I ssh into. finch has notification sounds and can run a command when certain events occur, letting you pass ...
2
votes
1answer
172 views
Script to let the user cancel a shell logout
I want to write a script to display a message and possibly cancel a logout from an interactive shell. This is because I often run background jobs in some of my shells and in the spur of the moment I ...
1
vote
3answers
462 views
Kill background SSH when shell exits
I'm trying to spawn an SSH from my bash profile script that runs in the background for connection sharing (via its control socket). The problem I'm running into is a reliable way to ensure the SSH ...
5
votes
3answers
6k views
How to write a bash script, that logs onto an other machine to do stuff?
Is it possible to write a bash script, that
would be started from machine A, logs in on a different machine B by ssh (both machines A and B would be Linux-Machines),
copys some files on to machine B
...
2
votes
1answer
166 views
xmodmap equivalent in bash
I'm constantly on bash via ssh, on a computer that doesn't have X. In my computer I've switched the keyboards' Super and Alt keys with xmodmap.
Is it possible to do it on the computer in which I log ...
15
votes
3answers
2k views
scp: How to Enable Autocompletion for Remote Paths?
I remote copied a file to my laptop using:
scp someFile USER@192.168.178.32:/home/USER/put/it/some/where/oh/damn/you/here
I am too lazy for this! I want to be able to autocomplete the remote path ...
3
votes
1answer
1k views
Real time system info script using ncurses and dialog
I'm trying to create a simple bash script that I can run over ssh that will display some basic system information using ncurses and the dialog command. I've tried two approaches so far:
1) Run dialog ...
3
votes
2answers
3k views
What are the different ways that a message can be displayed to a bash shell after a user logs in?
I have a CentOS 5.7 VPS using bash as its shell that displays a branded greeting immediately after logging in via SSH. I've been trying to modify it, but can't seem to find where it is in the usual ...
2
votes
1answer
130 views
Why doesn't my new cygwin .bashrc interactive check work?
I just updated Cygwin and the new .bashrc contains this line right at the top:
echo "BEFORE TEST"
# If not running interactively, don't do anything
[[ "$-" != *i* ]] && return
echo "AFTER ...
2
votes
2answers
411 views
Running a command on the remote host with interactive SSH (conditionally)
I would like to be able to automatically run a command on a remote host each time I log into that host, but within the current interactive SSH session.
Something like
ssh user@remotehost [run do.sh]
...
5
votes
3answers
2k views
How to check if I can log in to server via ssh?
I have a list of servers:
cat list.txt
10.10.10.10 servera
10.11.10.10 serverb
How can I check that I can log in via ssh to them or not? I mean by default I should be able to log in via ssh key ...
2
votes
3answers
653 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 ...
3
votes
1answer
390 views
wait for autossh connection to complete
I'm trying to create a script that runs a few commands that take a long time to execute and require a constant connection, but
autossh user@server
wait $! #or wait ${!}
commandA
commandB
doesn't ...
1
vote
2answers
295 views
Running any kind of login script when sh is linked to bash
My problem: My web host offers ssh to their shared server. I want to set up a couple of aliases and such, so I'm trying to get a login script of any flavor to run. If my shell was plain bash, I would ...
2
votes
2answers
474 views
Bash prompt keeps disappearing
I have a weird issue where my Bash prompt often completely disappears on a backspace. Doesn't make any sense to me, but it happens often:
I can't really think of why this is happening. Am I ...
3
votes
1answer
1k views
Compress a directory using tar/gz over SSH to local computer?
I'd like to essentially tar/gz a directory on a remote machine and save the file to my local computer without having to connect back into my local machine from the remote one. Is there a way to do ...
4
votes
2answers
558 views
Prevent tmux from starting up on SSH
I would like tmux to create a new-window when I ssh onto a machine from an existing tmux session. However, I do not want a tmux session started on the new machine!
I have the following in my .bashrc, ...
1
vote
1answer
194 views
restricting pushes to selected Mercurial repositories using `ssh` forced commands and `hg-ssh`
The context of this question is the hg-ssh script. It is helpful but not critical to know something about Mercurial. This script sets up a forced command using public keys so the given public key ...
0
votes
1answer
251 views
None of the dot-files is sourced when running bash via ssh, part II [duplicate]
Possible Duplicate:
dot file not sourced when running a command via ssh
This is a continuation of prev. my question dot file not sourced when running a command via ssh (I could not add ...
3
votes
1answer
1k views
dot file not sourced when running a command via ssh
When I run my program interactively, it works fine:
ssh somehost
$ ~/some/path/somescript.py
When I run my program over ssh directly, it doesn't work. The variable PYTHONPATH is not set, because ...
2
votes
2answers
323 views
I can create a file but I can't read from it
I've been using linux for a while, but I always had root access, so permission problems were no big deal. But now I don't have root access and it's driving me mad.
I have a ssh access to a web ...
8
votes
2answers
6k views
Is it possible to set Gnome Terminal's title to “user@host” for whatever host I'm connected to?
I'd like to set the terminal title to user@host so I can easily tell which machine I'm connected to from the window title. Is there a way to do this from SSH or from GNOME Terminal?
3
votes
5answers
1k views
ssh user@IP sh <command> missed environment variables
I use an approach
ssh user@IP sh [runme.sh]
to execute script remotely, this works fine. But I got one problem, that is in runme.sh, I can't get any envirnoment variables which are defined in ...
0
votes
2answers
632 views
Git Server Bash and SSH
I want to use Git over SSH with my Linode VPS running Ubuntu 10.04 LTS.
Instructions seem pretty easy, infact given I had already setup my SSH key etc..
All I had to do was instruct my local ...
3
votes
1answer
450 views
scp, globbing, and different shells
The other day at work I tried doing
scp remotehost:~/*.txt .
and I received an error about the *, *.txt file not found sorry, not at work and I forget the exact error
on my workstation I run zsh ...
6
votes
5answers
4k views
sh startup files over ssh
I have some important commands I need to execute before any sh shell starts. This is required for passing SSH commands in the SSH command (ssh host somecommand) and other programs that run commands.
...
16
votes
3answers
4k views
Quoting in ssh $host $FOO and ssh $host “sudo su user -c $FOO” type constructs
I often end up issuing complex commands over ssh; these commands involve piping to awk or perl one-lines, and as a result contain single quotes and $'s. I have neither been able to figure out a hard ...
4
votes
4answers
859 views
Copy text from one terminal into another
I am logged into ssh to a university account from my home computer. Then I find a file that I want to copy onto my local system. So I open a new shell terminal and am about to use scp to copy that ...
