Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6319305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:47:00+00:00 2026-05-24T15:47:00+00:00

How can I use SSH to send multiple commands to a networked system, logging

  • 0

How can I use SSH to send multiple commands to a networked system, logging in as root, and providing a password?

I know you can do:

ssh -l <username> target_host

to login, but I’m not sure how to provide the password and a command so it all gets executed in one line. I’m looking to make a script with many one-liner commands to the networked system that can be run as a one-off from another computer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:47:00+00:00Added an answer on May 24, 2026 at 3:47 pm

    ssh root@host “command”

    ie: ssh root@192.168.1.1 “cat /etc/fstab”

    If you are trying to execute multiple commands, I would suggest looking into some form of Expect scripting. I personally am a fan of Pexpect (Python).

    Using keys to circumvent password prompt (from man ssh):

    The file ~/.ssh/authorized_keys lists the public keys that are
    permitted
    for logging in. When the user logs in, the ssh program tells the
    server
    which key pair it would like to use for authentication. The
    client
    proves that it has access to the private key and the server
    checks that
    the corresponding public key is authorized to accept the account.

    The user creates his/her key pair by running ssh-keygen(1). This
    stores
    the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa
    (protocol
    2 DSA), or ~/.ssh/id_rsa (protocol 2 RSA) and stores the public
    key in
    ~/.ssh/identity.pub (protocol 1), ~/.ssh/id_dsa.pub (protocol 2
    DSA), or
    ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user’s home directory.
    The
    user should then copy the public key to ~/.ssh/authorized_keys in
    his/her
    home directory on the remote machine. The authorized_keys file
    corre‐
    sponds to the conventional ~/.rhosts file, and has one key per
    line,
    though the lines can be very long. After this, the user can log
    in with‐
    out giving the password.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I use expect to send a password to an ssh connection. say
My host allows limited access to SSH and Linux commands. However, I can't use
What commands I can use at ssh to export(download) mysql database using SSH?
Is it possible that Eclipse Secure Password Storage can use my ssh-agent to avoid
Is there a way I can use NSTask to ssh into another computer (in
In Bash, I can use the following code: [ $sshcmd = ] && sshcmd=ssh
blocks the SSH port so I can't use git, how can I bypass the
I know since the 3.0 SDK we can use accessories, so my question is
With the increasing use of Git or SSH copying or login, we can use
You can use more than one css class in an HTML tag in current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.