Hot answers tagged ssh
Your problem is here: ssh $machine ls -la && exit Your script sshs to the remote machine which runs your ls. ssh exits with success, && sees this and runs the next command which is exit, so your script exits! You don't need the && exit at all. When ls finishes, the connection will close and ssh will complete. Just remove that ...
You can use disown, it is a bash builtin: disown [-ar] [-h] [jobspec ...] Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a ...
You're not missing anything, you're adding something you shouldn't. The exit actually kills your session, it is not being run on the remote machine: ssh firstname.lastname@example.org command && other_command |---------------------| |------------| | |----------> A completely separate command to be | ...
exit isn't run remotely but on this side (and is unnecessary). If you need to perform more than one command (like cd, ls and possibly more), just pipe a script to ssh and execute it remotely with bash. Something like cat <<EOF | ssh "$machine" bash cd "$remote_dir" ls -la exit #if you actually needed this, it would be here, but you don't EOF
First, you need some configs for ssh server and ssh client. In Server, in /etc/ssh/sshd_config, make sure you accept TZ variable: AcceptEnv LANG LC_* TZ In Client, in /etc/ssh/ssh_config or ~/.ssh/config, make sure you send TZ variable: SendEnv TZ (The defaults are usually to send none from the client, and accept none on the server.) Then make alias ...
Use the TZ environment variable. E.g.: bash$ export TZ=US/Pacific bash$ date Mon Mar 3 00:31:17 PST 2014 bash$ export TZ=US/Eastern bash$ date Mon Mar 3 03:33:06 EST 2014 The possible values for TZ are in the directory /usr/share/zoneinfo (see, for example, the existence of /usr/share/zoneinfo/US/Pacific)
Assuming you have: A with ip address ip_A B with ip address ip_B C with ip address ip_C From a first terminal connect to the B and set a tunnel to C on ssh (port 10022 is used for the tunnel but it can be anything else): ssh ip_B -L10022:ip_C:22 Then from another terminal, you will be able to connect "directly" to C from A by using the tunnel you just ...
You need to take care of two things: Redirecting the standard input/output streams to/from nowhere. Forking the process into the background reparented by init. The "reparented by init"1 bit is the most crucial part, since otherwise the process will receive a HUP when you log out. The nohup command can block the HUP, and the now orphan process will then ...
Assuming you are working with httpd on a systemd based system - When logged into the server, you should run these commands: sudo systemctl enable httpd.service sudo systemctl restart httpd.service You can check to see if it is running on subsequent logins by running this command: systemctl status httpd.service
Only top voted, non community-wiki answers of a minimum length are eligible