Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

script for ssh-ing and logging out

  • 29-02-2012 10:19PM
    #1
    Registered Users, Registered Users 2 Posts: 3,457 ✭✭✭


    Hi,

    I'm trying to write a script that automatically ssh-es into a network, executes a command, and logs out

    ssh <login-node>
    <command>
    exit

    I know the trouble is with "scope". Are there ssh options that will let me get around this? So that I can perform the command on the login-node via a script executed off the login node?

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 1,193 ✭✭✭liamo


    If you want to log in via a script then you must set up ssh keys to remove the need for a password.

    The remote execution of the command is very simple :
    ssh myuser@myremotelocation "some command"

    That will log in to the remote location, execute the command and log out.


  • Registered Users, Registered Users 2 Posts: 3,457 ✭✭✭Morbert


    Thanks!


  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    Also check out expect. Can be useful also.


Advertisement