Tag Info

New answers tagged

2

ssh user@111.111.111.111 'cd ~/user/path && ./my_script.sh'


1

You need to use the OUTPUT chain to redirect an outbound connection to a local port. This rule will work as you need: iptables -t nat -A OUTPUT -p tcp -d 40.40.40.40 --dport 3306 -j REDIRECT --to-port 3306


0

Check this http://www.edwardawebb.com/web-development/keys-putty-cygwin-passwordless-login-ssh-scp , you have a script to make it easy in a lot of servers.


3

PUBKEY=$(cat ~/.ssh/id_rsa.pub); grep -q "$PUBKEY" ~/.ssh/authorized_keys || echo "$PUBKEY" >> ~/.ssh/authorized_keys This one-liner checks whether pubkey is already present in authorized_keys file, and appends it to the end of file if it is not present. ~/.ssh/id_rsa.pub here is path to pubkey being added ~/.ssh/authorized_keys here is a path to ...


0

try replacing ssh -t $line 'script /dev/null . /tmp/commands.sh' by ssh $line 'bash /tmp/commands.sh' you are scripting to /dev/null ?? if you are executing command interactively, tty will be allocated.


0

There are several tools available for doing what you want. My favourite is pdsh, which includes a pdcp (multi-host scp), pdsh (multi-host ssh), and dshbak (display multi-host output grouped by host) - dshbak is useful because pdsh executes commands in parallel on multiple hosts, not one host after the other. I've used pdsh many times on clusters, VMs, cloud ...


1

As gwillie said in his comment, connecting to a Virtual Box guest machine depends on the network settings of that virtual machine. The default settings seem to be NAT which will make the layer between the guest and the host behave like a NAT device (like e.g. a router) and is therefore most suited for situations that don't require access from the host to ...


1

Basically, you are talking about a chroot environment, when a user or group meets some usage restrictions by having only specific binaries and configs in their directory root level. It is possible to configure sshd to do that. /etc/ssh/sshd_config options: Match user john ChrootDirectory /var/john/ Put /bin, /etc, /sbin, /usr and other required ...


1

I assume you are mounting in /etc/fstab. There is a nobootwait option, from man to explicitly instruct mountall(8) not to hold up the boot for them There is also a degraded boot option for mdadm, which I have never used and I think it is used if OS is installed on raid: dpkg-reconfigure mdadm and tell mdadm to allow degraded boot IMO nobootwait ...


1

for HOST in $(grep -v '^#' db_hostlist2.txt) do echo "Checking for $HOST" ssh admin@$HOST <<EOF echo "Hostname : " \$(hostname) echo -e "Total DB is : \$(ps -ef | grep smon | grep -v grep | wc -l)\n" echo -e "Total DB is : \n\$(ps -ef | grep smon | grep -v grep |awk -F_ '{print \$3}')\n" EOF echo "$HOST Complete" done ...


0

I'm sure it ought to be possible. I can only suggest a hack where you use extra ssh connections to each carry another pair of file descriptors. E.g. the following proof of concept script does a first ssh to run a dummy command (sleep) to connect up local fds 5 and 6 to remote stdin and stdout, presuming these fds are the ones you want to add to the usual ...


0

this seems over complicated. my proposal : for i in $(cat db_hostlist2.txt | grep -v '^#') do echo "Checking for $i" ssh admin@$i '. ./.bashrc; echo "Hostname : "hostname ; echo -e "Total DB is : " ; ps -ef | grep -c [s]mon ; echo " DB are : " \ ps -ef | grep [s]mon |awk -F_ \'{print $3}\' ' ...


3

Simply start the command with the -i switch sudo sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config From man sed -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if extension supplied). The default operation mode is to break symbolic and hard links. This can be changed with ...


2

% exec zsh % MAGIC=1 exec zsh hello world % grep -1 hw .zshrc function hw { print "hello world" } [[ -n $MAGIC ]] && hw % So uh remotely % ssh localhost "MAGIC=1 zsh -i" or something


3

You can do this using socket forwarding, which is available since openssh-6.7. This is some kind of pipe. This technique is described for example here: http://www.25thandclement.com/~william/projects/streamlocal.html You will gain two-direction route for your data. There is example with mysql: Proxy MySQL client connections on a remote server to your ...


1

Your SSHd has not been setup. Do that first and try again.


1

/me wished he could comment sshd needs to (typically, but though you didn't specifiy the exact use case(s) etc.) allocate a pty per login, however, in your case, ssh "echo hi; sleep 100s" does NOT allocate a pty, so no need for the kernel.pty.max setting... unless you want thousands of users loggedin*... to test that, you'll need to add the -t option to ...


2

At least in OpenSSH, the actual numerical offset is determined by a parameter X11DisplayOffset in the sshd configuration file (/etc/ssh/sshd_config on Ubuntu): X11Forwarding yes X11DisplayOffset 10 From man sshd_config X11DisplayOffset Specifies the first display number available for sshd(8)'s X11 forwarding. This prevents sshd from ...


2

When you connected to your instance you used ssh and it created a small server on the remote that listens on port 6010 for connections which are forwarded back over your ssh connection. When you run DISPLAY=localhost:10 xclock the application converts 10 to 6010 (an X11 convention) and connects to that local port to get the data sent back to you.


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 ...


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 ...


1

Remote GUI (X11) connections go through TCP port 6000+n where n is the display number¹. So the two messages refer to the same problem: some program tried to connect to display 12 and failed. Emacsclient doesn't make X11 connections, Emacs does. So if you see this message, it means Emacsclient managed to contact Emacs and tell it to open a new frame. ...


0

From what I understand, I think what you're looking for was answered on StackExchange's ServerFault site: here. Since this deals more with networking, and network/server-administration tools that may be a better site to ask this sort of question in the future. There they are talking specifically about setting up a tunnel for SSHing into host C from host A, ...


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

Your problem is probably the fact that when you log off locally your internet connection is being cut off and/or the ssh is stopped. Edit:You cannot use internet without logging in the local account.I as far as I am aware it seems it cannot be done without logging in.


0

I think this command will do the trick ssh user@host "cd /path/to/data/;tar zcf directory_name" | tar zxf Now, first of all you have to execute this command from the target host. And details to be explained: ssh user@host will open connection to host machine, from where the data is to be transfered. cd /path/to/data will take to the directory where ...


0

If I read your question correct you are not able to ssh from Foo to Bar, otherwise it would be as easy as: win> ssh -L 2210:bar:22 user@foo Where you probably replace ssh with PuTTY and setup the correct tunnel, but this will hopefully illustrate the way you should set it up... Then you can start a ssh session to bar using: win> ssh -p 2210 ...


0

I managed to solve this myself with some time and effort so ill post my solution here in hopes that it will save someone some time in the future. ssh -o ProxyCommand="nc -X connect -x '<proxy ip>:<proxy port>' %h %p" root@<remote ip> This is the command that im now using to SSH onto my server through my proxy. If you wish to use the same ...


0

What are you using for DNS? nslookup `hostname` The output will show you your DNS server - this is where your problem is.


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' ...


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


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.


0

You should use code markup for pasting in a log file, but from what I can tell: sshd[32711]: debug1: PAM: password authentication failed for root: Authentication failure Aug 26 20:32:29 Seems relevant. Are you sure you are using the correct password for the root user of your docker image? Also, did you restart the sshd service (in the docker image) so ...


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 ...


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


0

On my (standard) Ubuntu environment I got the xterm over ssh failure message "... suid-root program..." (see above), even with all the proper forwarding settings. This behavior went away a soon sshd is configured to use only IPv4, because of an X11 forwarding bug in SSH if IPv6 on the system is disabled. vi /etc/ssh/sshd_config AddressFamily inet service ...


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 ...


0

If you do not want to change any server configurations Go to $HOME/.ssh/config and add Host * GSSAPIAuthentication no


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 - > ...


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 ./


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 ...


0

The issue is solved. Turns out there were some issues with the firewall behind which the non-connecting client was sitting. After clearing these up, the client connects properly using pub key authentication


0

I've got vsftpd running and it works fine for FTP, and when I log on as the user via SSH it defaults to their home directory but they can then just "cd /" and go where they want. Yes. SSH is shortcut of Secure Shell. After authentication you have the same access as if you were sitting next to the computer and were typing into the terminal. I realize ...


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) ...


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\''" \


0

You need to enclose the remote command in quotes to execute it all on remote server, otherwise you run everything after pipe on local host, which is not what you want (as described in comments): foo=`ssh $remoteuser@$remoteaddr "ls -tr1 /mnt/backup1tb/testarossa/test | tail -n +5 | xargs -d '\n' rm -f"`


2

Doing a diff in both output I see this: They look kind of the same but one is doing different authentification, you should check the settings of your ssh server. One is doing md5 and the other one sha1, so check it out. Also, I don't know if you already know this but the clients are different. So to make an assumption of why one works and the other ...


3

You can use "Remote Desktop Viewer" and connect using RDP protocol to windows machine (you need to allow this on windows side). You can't do this using ssh, since windows is not running sshd server nor X11 client by default.



Top 50 recent answers are included