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;
}
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
ssh users ubuntu-18.04 chown
New contributor
New contributor
New contributor
asked 3 mins ago
ehdaehda
1
1
New contributor
New contributor
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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