SSH: User name of the remote machine's user? Announcing the arrival of Valued Associate #679:...

do i need a schengen visa for a direct flight to amsterdam?

Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?

Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?

What's the purpose of writing one's academic bio in 3rd person?

How discoverable are IPv6 addresses and AAAA names by potential attackers?

Using et al. for a last / senior author rather than for a first author

List *all* the tuples!

What is a Meta algorithm?

When to stop saving and start investing?

Is there a concise way to say "all of the X, one of each"?

What is the musical term for a note that continously plays through a melody?

How to do this path/lattice with tikz

Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?

If Jon Snow became King of the Seven Kingdoms what would his regnal number be?

How to find all the available tools in macOS terminal?

Is 1 ppb equal to 1 μg/kg?

Antler Helmet: Can it work?

How does a Death Domain cleric's Touch of Death feature work with Touch-range spells delivered by familiars?

Why is "Captain Marvel" translated as male in Portugal?

What causes the vertical darker bands in my photo?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

How can I make names more distinctive without making them longer?

What's the difference between `auto x = vector<int>()` and `vector<int> x`?

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]



SSH: User name of the remote machine's user?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Come Celebrate our 10 Year Anniversary!Can I use SSH key authentication to log into a remote system with a different username?SSH back to the local machine from a remote SSH sessionchown, chmod & bad settings on /home/user/.ssh directory in fresh install of CentOS 6Rsync with ssh-keygen to ssh user with limited commands and specifc directoryCentOS 6 restrict user ssh access to his home folderHow to rsync to remote machine with user1 for ssh and user2 as remote rsyncer?ansible user variable overwritten by local machine userHow to properly use rsync Push with SSH on local macOS to remote DebianHow to restrict outbound ssh username credential to current user onlySSH to server as one user, switch to root and create mysql dump - how to script this





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I need to run a script from my local machine on a remote server via SSH. One of the operations involves chown and for that I need to have a programatic access to the server's user name (I am looping through a couple of servers)



But when using whoami for the chown argument I get the username of my user on the local machine that is SSHing in.



If I check with simple whoami it gives the remote user but I cannot capture it into a variable.



How to get the remote user name?



ssh $server << EOF
pwd
whoami
rsync /some/stuff ./dump
chown `whoami`:`whoami` ./dump
EOF









share







New contributor




ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    I need to run a script from my local machine on a remote server via SSH. One of the operations involves chown and for that I need to have a programatic access to the server's user name (I am looping through a couple of servers)



    But when using whoami for the chown argument I get the username of my user on the local machine that is SSHing in.



    If I check with simple whoami it gives the remote user but I cannot capture it into a variable.



    How to get the remote user name?



    ssh $server << EOF
    pwd
    whoami
    rsync /some/stuff ./dump
    chown `whoami`:`whoami` ./dump
    EOF









    share







    New contributor




    ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I need to run a script from my local machine on a remote server via SSH. One of the operations involves chown and for that I need to have a programatic access to the server's user name (I am looping through a couple of servers)



      But when using whoami for the chown argument I get the username of my user on the local machine that is SSHing in.



      If I check with simple whoami it gives the remote user but I cannot capture it into a variable.



      How to get the remote user name?



      ssh $server << EOF
      pwd
      whoami
      rsync /some/stuff ./dump
      chown `whoami`:`whoami` ./dump
      EOF









      share







      New contributor




      ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I need to run a script from my local machine on a remote server via SSH. One of the operations involves chown and for that I need to have a programatic access to the server's user name (I am looping through a couple of servers)



      But when using whoami for the chown argument I get the username of my user on the local machine that is SSHing in.



      If I check with simple whoami it gives the remote user but I cannot capture it into a variable.



      How to get the remote user name?



      ssh $server << EOF
      pwd
      whoami
      rsync /some/stuff ./dump
      chown `whoami`:`whoami` ./dump
      EOF







      ssh users ubuntu-18.04 chown





      share







      New contributor




      ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 mins ago









      ehdaehda

      1




      1




      New contributor




      ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      ehda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          ehda is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f963224%2fssh-user-name-of-the-remote-machines-user%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          ehda is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          ehda is a new contributor. Be nice, and check out our Code of Conduct.













          ehda is a new contributor. Be nice, and check out our Code of Conduct.












          ehda is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f963224%2fssh-user-name-of-the-remote-machines-user%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

          Список ссавців Італії Природоохоронні статуси | Список |...

          Українські прізвища Зміст Історичні відомості |...