Script to remote login into server

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am using Ubuntu bash. I want to remote login to server through shell, it will give me its own command line. Then enter 'shell' followed by login credential again followed by a command. I need that command output printed on my screen. Please suggest, how do I do that?







share|improve this question


















  • 4




    I think you may be looking for the ssh command? To log into a remote machine you can do: ssh [user]@[hostname|ip address]
    – Jesse_b
    Dec 15 '17 at 14:50














up vote
0
down vote

favorite












I am using Ubuntu bash. I want to remote login to server through shell, it will give me its own command line. Then enter 'shell' followed by login credential again followed by a command. I need that command output printed on my screen. Please suggest, how do I do that?







share|improve this question


















  • 4




    I think you may be looking for the ssh command? To log into a remote machine you can do: ssh [user]@[hostname|ip address]
    – Jesse_b
    Dec 15 '17 at 14:50












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using Ubuntu bash. I want to remote login to server through shell, it will give me its own command line. Then enter 'shell' followed by login credential again followed by a command. I need that command output printed on my screen. Please suggest, how do I do that?







share|improve this question














I am using Ubuntu bash. I want to remote login to server through shell, it will give me its own command line. Then enter 'shell' followed by login credential again followed by a command. I need that command output printed on my screen. Please suggest, how do I do that?









share|improve this question













share|improve this question




share|improve this question








edited Dec 15 '17 at 16:20









Stephen Rauch

3,248101227




3,248101227










asked Dec 15 '17 at 14:47









Viral Patel

1




1







  • 4




    I think you may be looking for the ssh command? To log into a remote machine you can do: ssh [user]@[hostname|ip address]
    – Jesse_b
    Dec 15 '17 at 14:50












  • 4




    I think you may be looking for the ssh command? To log into a remote machine you can do: ssh [user]@[hostname|ip address]
    – Jesse_b
    Dec 15 '17 at 14:50







4




4




I think you may be looking for the ssh command? To log into a remote machine you can do: ssh [user]@[hostname|ip address]
– Jesse_b
Dec 15 '17 at 14:50




I think you may be looking for the ssh command? To log into a remote machine you can do: ssh [user]@[hostname|ip address]
– Jesse_b
Dec 15 '17 at 14:50










1 Answer
1






active

oldest

votes

















up vote
1
down vote













ssh HOSTNAME "run_command with arguments"


will execute the command run_command and pass it two arguments - 1: "with" and 2: "arguments" ;-)
OUTPUT will go to stdout .. as usual
So if you want to check the files in a directory for evil stuff, for example:



#!/bin/bash
host=my-server.biz
check="/opt/path/to/check"
list=`ssh $host "ls $check"`
evil=`echo -e "$list"|grep -c "evil"`
if [ $evil -eq 0 ]; then
echo "all is well"
else
echo "the end is nigh"
fi





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411072%2fscript-to-remote-login-into-server%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    ssh HOSTNAME "run_command with arguments"


    will execute the command run_command and pass it two arguments - 1: "with" and 2: "arguments" ;-)
    OUTPUT will go to stdout .. as usual
    So if you want to check the files in a directory for evil stuff, for example:



    #!/bin/bash
    host=my-server.biz
    check="/opt/path/to/check"
    list=`ssh $host "ls $check"`
    evil=`echo -e "$list"|grep -c "evil"`
    if [ $evil -eq 0 ]; then
    echo "all is well"
    else
    echo "the end is nigh"
    fi





    share|improve this answer
























      up vote
      1
      down vote













      ssh HOSTNAME "run_command with arguments"


      will execute the command run_command and pass it two arguments - 1: "with" and 2: "arguments" ;-)
      OUTPUT will go to stdout .. as usual
      So if you want to check the files in a directory for evil stuff, for example:



      #!/bin/bash
      host=my-server.biz
      check="/opt/path/to/check"
      list=`ssh $host "ls $check"`
      evil=`echo -e "$list"|grep -c "evil"`
      if [ $evil -eq 0 ]; then
      echo "all is well"
      else
      echo "the end is nigh"
      fi





      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        ssh HOSTNAME "run_command with arguments"


        will execute the command run_command and pass it two arguments - 1: "with" and 2: "arguments" ;-)
        OUTPUT will go to stdout .. as usual
        So if you want to check the files in a directory for evil stuff, for example:



        #!/bin/bash
        host=my-server.biz
        check="/opt/path/to/check"
        list=`ssh $host "ls $check"`
        evil=`echo -e "$list"|grep -c "evil"`
        if [ $evil -eq 0 ]; then
        echo "all is well"
        else
        echo "the end is nigh"
        fi





        share|improve this answer












        ssh HOSTNAME "run_command with arguments"


        will execute the command run_command and pass it two arguments - 1: "with" and 2: "arguments" ;-)
        OUTPUT will go to stdout .. as usual
        So if you want to check the files in a directory for evil stuff, for example:



        #!/bin/bash
        host=my-server.biz
        check="/opt/path/to/check"
        list=`ssh $host "ls $check"`
        evil=`echo -e "$list"|grep -c "evil"`
        if [ $evil -eq 0 ]; then
        echo "all is well"
        else
        echo "the end is nigh"
        fi






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 15 '17 at 16:05









        flowtron

        28616




        28616






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411072%2fscript-to-remote-login-into-server%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay