0

I want to open a terminal and run a command on a remote computer through SSH. I don’t need to see what is happening in that terminal, but I cannot make it work.

I know to open a browser, for example Chrome, and open to a website it would be:

ssh ssh@login -a “http://www.websitehere.com”

Is there an equivalent for Terminal?

  • 1
    Please clarify “cannot make it work” – Wilfred Smith Apr 22 at 2:52
  • You don’t need to open a terminal on the remote computer. Use SSH to send the command. BTW, the example you provide invokes the default browser, which should be Safari in nearly all cases. – Wilfred Smith Apr 22 at 2:54
  • Thank you for the advice, the reason why I wanted to open a new terminal from the SSH was so that I could start large downloads from my computer on a slow connection to a computer on a faster connection using curl. I have managed to come up with an apple script to do this, although it probably looks quite ugly. – Mangus Apr 23 at 12:32
1

I think you're just confusing some of the concepts here. When you SSH to another computer you're connecting to it in an interactive terminal. You can run commands logged into another computer through this SSH connection.

Example

Here I'm logged into my Macbook (unagi) as myself (smingolelli).

$ hostname
unagi

$ whoami
smingolelli

Now we SSH to another computer on my LAN (mulder) as another user that's local to that system (root).

$ ssh mulder.bub.lan -l root
Last login: Sun Apr 21 23:05:32 2019 from 192.168.1.95

$ hostname
mulder.bub.lan

When I'm done I simply exit this interactive SSH connection to another host and I'm back on my original Macbook host.

$ exit

  • Thank you for the advice, the reason why I wanted to open a new terminal from the SSH was so that I could start large downloads from my computer on a slow connection shut this computer to a computer on a faster connection using curl. I have managed to come up with an apple script to do this, although it probably looks quite ugly but it seems to be working although its not elegant. When you use SSH if you shut down the terminal this stops the process on the target computer is that correct? – Mangus Apr 23 at 12:35
  • on run {input} set fistv to input if application "Terminal" is running then tell application "Terminal" reopen do script "ssh 192.168.1.50" in window 1 delay 10 do script "osascript -e 'tell application \"Terminal\" to do script \"echo " & fistv & " \"'" in window 1 delay 10 do script "osascript -e 'tell application \"Terminal\" to do script \"curl -# -O " & fistv & "\"'" in window 1 end tell – Mangus Apr 23 at 12:35
  • @Mangus - you can background the download if you're doing it via wget or curl would be 1 method, better still would be to use a tool such as screen or tmux. These tools allow you to disconnect from a shell and it'll still exist and later to resume a connection to it. – slm Apr 23 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .