New answers tagged

0

What's probably happening is that some network equipment somewhere between the client and the server terminates connections that have been idle for a certain time. Such network equipment (firewalls, NAT appliances, …) often kills idle connections after a while to save memory (it's a defense against denial of service, but it does tend to be an annoyance to ...


0

I had a similar problem, I seemed to only see strange client_input_channel_req: channel 0 rtype exit-status reply 0. User I was trying to ssh into didn't have a shell by default. I ran the following: chsh -s $(which sh) username And then I was able to ssh. Note: Running su username was returning exit-code 1 (was failing) and now it just works.


1

Here is fragment from my working script. send_user "FILE \"FILETEMPL\" is copied to active.\n" spawn scp -l 60 FILETEMPL root@IP:PATHTEMPL/FILETEMPL # After scp we should wait "#" or "100%". set timeout 600 expect { "password: " { send "PASS\r" expect { "100% " {...} "password: " { ...


0

The Tiger's x0vncserver could help share the existing X server regardless of the desktop in use: NAME x0vncserver - TigerVNC Server for X displays SYNOPSIS x0vncserver [options] x0vncserver -version DESCRIPTION x0vncserver is a TigerVNC Server which makes any X display remotely accessible via VNC, TigerVNC or compatible ...


0

If you really reluctant about writing scripts you may find Here document handy. Short said, you add << SOMETEXMARKER to the end of the line and continue entering as many commands for remote host as you like. Then, on the last line you enter (at the very beginning of the line) the same SOMETEXTMARKER and that makes the entered commands get executed ...


2

It might be easier to simplify the command so that you have fewer special characters on which the shell might choke: ssh jboss@myTargetServer 'ps -p $(cat /var/run/jboss-as/jboss-as-standalone8.pid) -o %cpu= 2>/dev/null' The trailing 2>/dev/null throws away the error text in the event that the PID file either cannot be found or contains a stale PID. ...


1

The second command as you have it runs the code part ($()) in local subshell. You need to make it run on the other side by escaping special characters (basically $): ssh jboss@myTargetServer tmpValue=\$(cat /var/run/jboss-as/jboss-as-standalone8.pid) \ && top -b -U jboss -n 1 |grep \$tmpValue |awk '{print $9}' or put it all into the apostrophes ' ...


-1

If you would like a secure channel, then you can use ssh. You would need to enable X11 forwarding on both the client and server (/etc/ssh/ssh_config and /etc/ssh/sshd_config, X11Forwarding, TrustedX11Forwarding).


2

I think you use, Vino. Vino is the GNOME desktop sharing server. This (vino) is default package in most of the distribution along with gnome.


2

I would recommend putting those commands into a script that you remotely call with ssh. Otherwise you'd need to put the whole "remote" part of the command line into quotes and properly escape everything inside. This can be tedious and error prone. That's why remote script call.


3

Problem : * is not getting expanded ; there really is no such file named * , so grep reports that. Solution : remove the last * ; it will work with -r , making grep look into all the files in that Directory.


2

mosh uses the locale environment supported by ssh. While mosh apparently has no verbose- or debug-options, you can tell it what ssh command to use when connecting and by adding a -vvv option can have ssh show what locale variables it sends. For example, starting with mosh -ssh='ssh -vvv' root@server you might see debug1: Sending env LC_ALL = C ...


0

I got a fix to the issue. 1. I created a new shh key-pair under jenkins user. 2. Added the .pub key to the remote server. While doing ssh from the jenkins server the newly generated private key is used. Now both ssh and scp work as part of the build step. Thank you


2

No. Doing that would make no sense at all. It would be like asking for the light to stay on when you flip off the switch. The only way to do that would be to invalidate the switch.


2

The hosts key needs to be added to the "known_hosts" file of the client, in your case the user, under whos account the jenkins server is run. So what you need to do is: Enable ssh login for the jenkins-user log in as jenkins ssh to the remote server answer the question "should the servers identity be added.." with yes.. Then you're done. Afterwards, the ...


0

For me worked fine like this, but with notice about: Pseudo-terminal will not be allocated because stdin is not a terminal ssh -t username@hostname1 << 'EOS' sudo sh hostname EOS Pseudo-terminal will not be allocated because stdin is not a terminal. hostname1


0

If you grant a user access to login to an account, you grant full access to that account and any means you try to detect the difference can easily be overcome with basic environment manipulations. If you wish to block the login and ssh, you could add instructions in your /etc/sudoers file such as: UserName ALL = !/bin/bash UserName ALL = !/bin/sh ...


1

What you are doing there is at least 'complicated'. As far is i understood, you connect to one server, and tell it to sync to another server. For ease of use, you may specify port and user to use in the local ssh configuration for a particular host. for instance, if you add the following lines to the file ~/.ssh/config (/home/username2/.ssh/config) on the ...


0

I have encountered this on Mac OS X where the configuration in ~/.bashrc had an problem which caused ssh to work, but sftp to not work. @stéphane-chazelas seems to have the right idea in the comments above. On the remote system via SSH, rename ~/.bashrc to ~/.bashrc-MOVED and try it again and see if it works; then restore ~/.bashrc and determine the issue. ...


0

Outcoing connections to port 22 seems to be blocked in your school network. You can try to make your ssh server to listen some other port where you don't have any services listening on like e.g. 443 which might not be blocked. Just add.. Port <alternative_portnumber> ..to/etc/ssh/sshd_config in your server and restart ssh service. Then try again ...


2

ssh: connect to host IP port 22: Operation timed out This message is indicating that the secure shell client is not able to establish a connection to the server to which you are attempting to connect. As you mention this only happens from within a school network (and that you are able to connect from elsewhere), it's exceedingly likely that the campus ...


1

The usual way to do this without changing too much is to copy the file to the remote and then execute it, hence keeping stdin available for your tty input. Eg scp -P 2202 ~/scripts/$2 root@server$1:./myscript ssh -t root@server$1 -p2202 bash ./myscript $3 or if you cannot scp replace that line by ssh root@server$1 -p2202 'cat >./myscript' ...


1

In general please AVOID using sshpass with a password. Everything you wrote can be observed by other users with the ps command and this SHOULD be of concern to you. Second problem there is here, I don't see you specifying -t option. This means you have disabled Defaults requiretty In your /etc/sudoers, which can have security implications. If you ...


0

Connecting to an X11 display requires two pieces of information: the display name (normally passed in the DISPLAY environment variable) and the cookie, which is a password for the display that every application must show when connecting. Typically the cookie is stored in ~/.Xauthority, but it can be stored in a different file indicated by the XAUTHORITY ...


2

who only shows logins. For example, tmux / screen opens a pty but I think it doesn't count as a login. I think you can find the process (pid) with fuser /dev/pts/14. (I would use lsof on Linux, but fuser should be available on any posix system).


4

No, you have little control over how the private keys are configured, and you can't detect / enforce any passphrase requirement on them. You also can't limit the size of the keys without modifying the OpenSSH source itself (i.e. there is no configuration option to achieve a minimum key length limit). You can limit the type of public keys accepted using the ...


1

Using information from your comment, the solution seems to be to fix the underlying issue rather than answer the question you've actually asked. I use scp to move a locally built .jar from my machine to the home folder on the linux server. I then have to move that .jar from my home folder to a shared folder where the .jar can be executed. To move that ...


1

Something like: ssh host; echo "Reconnect?"; while read; do ssh host; echo "Reconnect?"; done in your command should do the job. It connects to your host and when the connection is lost, it asks you for a reconnect. Or just simply as you wanted: ssh host; bash will connect to your host and when the connection ends, it gives you new shell


1

I have a situation that needs a solution like the original poster asked. I am recording a hockey game on my computer in one location and I'd like to watch it on my TV at another location. The link between the two locations allows the copy to go at about 1.3Mb/s and the recording video is about 1.5Mb/s. So, I want to copy the file as it starts recording. This ...


2

You can start gpg-agent remotely and create remote UNIX socket port forwarding to your host and then use the gpg-agent locally. In short Connect to the server and start gpg-agent (if it is not running yet) and ensure it stays running. It is listening on socket defined in environment variable $GPG_AGENT_INFO. Store the path: eval `gpg-agent --daemon` ...


1

You can change the TCP-LISTEN:5000 to TCP-LISTEN:5000,reuseaddr but the problem may simply be that, for example, during testing you are interrupting the ssh with Control-C and this is not stopping the socat on the remote. Note that you can avoid having to repeatedly launch socat to do the same thing over again by simply asking it to fork and listen for a ...


1

In most of these cases, the problem comes from the IP being blocked on the server for security reasons such as too many failed login attempts and the such. That kind of situation can only be resolved by the host's security team or waiting long enough for the automatic block to be removed, typically 24 hours.


1

Run: sudo systemctl enable sshd.socket To enable service to run on boot.


1

You can set the date with ssh root@embedded "date -s '$(date)'" (i.e. run date locally and give the output to date -s on the remote system.) Of course you need another ssh command to open the interactive session, so either use keys and ssh-agent or a master connection to login. Normally, I would have also recommended using NTP, but if the machine ...


1

Yes, a program running over SSH will depend on its output going somewhere. If the connection is slow, the output must be buffered somewhere, and buffers cannot be infinite, so the program must block if they are filled. Note that the output might not necessarily go to a terminal: consider running something like ssh user@somewhere "cat file.txt" > ...


0

Looking at the log /var/log/secure showed that it was just downright refused. I'm somewhat new to centos since I'm mainly a debian kind of guy, so I was unaware of /var/log/secure After checking this and doing a bit of searching, it turns out PermitRootLogin no needs to be PermitRootLogin without-password if you want to specifically use just keys for root ...


0

Turns out ssh doesn't like the way I set up my DISPLAY. Changing that environment variable (on Cygwin) to 127.0.0.1:0.0 solved the issue. It sure wasn't gonna like my DISPLAY since it had a typo. :0/0 instead of :0.0.


9

An SSH connection can die prematurely if the underlying TCP connection receives a packet with the RST flag. That could happen if one side sends a packet (which might be a periodic SSH keepalive probe) but doesn't receive a TCP acknowledgement in a reasonable amount of time, or if a router decides that the connection has been idle too long, or if an ISP is ...


0

RFC 4254 Section 6.9 Message name "window-change" is sent with the new dimensions. On the client side it may be true the original SIGWINCH is caught, but it gets sent via that message I believe. https://www.ietf.org/rfc/rfc4254.txt


23

The output of programs is buffered, so if the connection is slow the program will be halted if the buffer fills up. If you use screen, it has a buffer as well that it uses to try and display to a connected session. But a program connected in the screen session will not be stopped if screen cannot update the remote terminal fast enough. Just like when a ...


0

First of all check that /etc/ssh/sshd_config is valid and service should listen on port 22. Then check iptables rules: iptables -L -nvx (Eventually /etc/iptables/rules.v4 if you're chrooted into the system). You can check /var/log/auth.log for messages like: error: Could not load host key: /etc/ssh/ssh_host_rsa_key which might mean that some keys are ...


0

Set LogLevel to DEBUG in sshd_config, and I think you'll find (in auth.log of course) a reason why you publick key is refused.


1

I agree this might be a duplicate of the question linked, but there are times when those options in the sshd_config just don't work. In those situations, I use tmux on the target server with a lower status bar which has the time in it, updated every 15 seconds.


2

There's watch, loops with sleep, crontab, and many other options: watch -n 60 echo hello world while :; do echo hello world; sleep 60; done crontab -e #...


2

man ssh-keyscan It scans local or remote IP addresses to return the public key. For example, ssh-keyscan 127.0.0.1


0

You mention that you're using scp inside your script to download packages. Your problem is with that bit. The issue is that, when you run ssh in this form: ssh user@host command ... there is no pseudo terminal allocated to the script that is running. scp tries to prompt for a password, but it needs a pseudo terminal for that, so without one, you get the ...


-3

Try this: ssh root@hostb 'bash -s' < local-script.sh


0

It's most likely that the CHAT variable is not defined in the environment the motd scripts are being run; it's local to your shell process, not globally set. If you start a new shell session, you should observe that the variable is not available. By default, the shell substitutes undefined variables as empty, so the line $CHAT is treated as empty, a no-op. ...


8

If shell of the host you are sshing to is bash version >= 4.0, you can enable the globstar option. When enabled, the ** glob will recursively match subdirectories. So the following should do what you need: shopt -s globstar for gz_file in **/*.jpg.gz; do gzip -d "$gz_file" done No manual recursing into subdirectories required.


1

There exist parallel ssh wrappers -- here are a few I found on CentOS7/EPEL: Name : pssh Repo : epel/x86_64 Summary : Parallel SSH tools URL : http://code.google.com/p/parallel-ssh/ License : BSD Description : This package provides various parallel tools based on ssh and scp. : Parallell ...



Top 50 recent answers are included