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 7695561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:34:21+00:00 2026-05-31T21:34:21+00:00

Ok heres what I’m trying to do I have to setup an SSH session

  • 0

Ok heres what I’m trying to do

I have to setup an SSH session to a linux machine and issue a command like “ls” or cp.

heres the snippet

            SshStream  ssh = new SshStream ("myhost","root","pass");
            ssh.Prompt ="#";
            ssh.RemoveTerminalEmulationCharacters = true;
            byte[] byt = System.Text.Encoding.ASCII.GetBytes("rm vivek");
            Array.Resize (ref byt,byt.Length +3 );
            byt[byt.Length-1]=(byte)'\r';
            byt[byt.Length - 2] = (byte)'y';
            byt[byt.Length - 3] = (byte)'\r';
            ssh.Write(byt);

            Console.WriteLine(ssh.ReadResponse());

The thing is commands like “ls” are simple you type it and it gives the output, but commands like rm

require addtional acknowledement like an “y”

as you can see from the above snippet the code essentially generates a bytes sequence like

rm vivek [enter] y [enter]

But it doesnt work, it is as if it is still wating for the input at

[root@host ~]# rm vivek
rm: remove regular file `vivek'?

What am I doing wrong here?

Hope the question is clear.

P.S I have tried the SSHExec sample again the same result.

  • 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-31T21:34:22+00:00Added an answer on May 31, 2026 at 9:34 pm

    Why not just do rm vivek -f to avoid the confirmation ?

    Otherwise, just expect the question and answer it before reading the response:

     ssh.Write(byt);
     ssh.Expect("rm: remove .*");
     ssh.WriteLine("y");
     Console.WriteLine(ssh.ReadResponse());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Heres an interesting issue, I'm trying to check if a LINQ Entity exists in
heres a issue i have. When a user logs in on the website, it
Heres my code: AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(What's Your name?); alert.setMessage(Seems like you're
Heres what I'm trying to do. I want to have a homepage with my
Heres a screenshot to make it clear. I'm trying to figure out a robust
Heres the markup: <div id='0203' class='threadWrapper'> <div class='littleme'> I am trying to send the
Heres my saga - I'm trying to link http://www.example.com to my shopping cart on
Heres my array NSMutableArray *arrayTmp= [[NSMutableArray alloc] init]; I populate it like this double
Heres my code: //Setup days $data['days']['FALSE'] = 'Day'; //Setup months $data['months'] = array('FALSE' =>
Heres my Situation. Im trying to relaod a div in a page with load().

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.