Re: get logged in username

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the last episode (Sep 17), Mohsen Alimomeni said:
> How can I get the logged in username under remote command execution? I am
> using openssh version 4.0 under fedora core 4.
> 
> more explanation:
> when I do "ssh admin@host", I can get the username "admin", by the
> command "who -m", since there is tty which the username is assigned to
> it. But suppose I want to execute a remote command "ssh admin@host
> myprog", I want to get the username inside the myprog. The command
> "who -m", doesn't work because no tty is created for the user.
> How can I get the username in this case?

Try "whoami", or "id -un".  Your system may also store the username for you
in the USER or LOGNAME environment variables.

-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxxxxx

[Index of Archives]     [Open SSH Unix Development]     [Fedora Users]     [Fedora Desktop]     [Yosemite Backpacking]     [KDE Users]     [Gnome Users]

  Powered by Linux