BlackberryPerfect938 · 2022-09-18 07:20
I have server which connect using ssh, my ssh configuration denies root user and only allows connection via my admin user with ssh key. For each service i made a separate user which only he and admin can access service related files. Question is how to i access (read/write) files as other user? I know i can use eshell and switch users using my shell like this "su - user4" but how to i do this using C-x C-f?
If my question is unclear please point it out in a comments. Thanks :)
podtatranec · 2022-09-18 07:36
I guess you are looking for https://www.gnu.org/software/emacs/manual/html_node/tramp/Multi_002dhops.html?
[deleted] · 2022-09-18 07:36
[deleted]
BlackberryPerfect938 · 2022-09-18 07:58
Yea, that seems pretty close to what i want, tho i'm going to be honest i'm trying to understand how to use this `tramp-default-proxies-alist` list to change users in remote ssh session.
I found this dired syntax works for me: `C-x C-f /ssh:ipaddress|sudo:user4@ipaddress:`
user4 - being user that i want to switch to
ipaddress - being, well. my servers public ip
address in my case
Tho i dont understand why i need to retype ipaddress a second time, thats pretty cumbersome.
BlackberryPerfect938 · 2022-09-18 08:38
Also another question, when i am connected to ssh session in eshell why i cant do this:
`ps aux | grep 'pattern'` for example?
I researched about eshell a bit and i know that eshell sometimes uses it's own lisp commands that replace built-in commands, to invoke built-in command you have to prefix it with \*
from: [https://www.gnu.org/software/emacs/manual/html\_mono/eshell.html](https://www.gnu.org/software/emacs/manual/html_mono/eshell.html) section: 2.3 Built-in commands:
>Several commands are built-in in Eshell. In order to call the external variant of a built-in command foo, you could call \*foo
Typing this `which grep` outputs: `eshell/grep is a byte-compiled Lisp function in ‘em-unix.el’.` so i should use *grep to invoke built-in command
But this `ps aux | *grep pattern` also does not work. What did i do wrong here?
xtifr · 2022-09-18 09:26
Doesn't `/ssh:user4@ipaddress:` work? You can't get root that way, since ssh won't allow direct root logins, but for a normal user account, that's not a problem.
BlackberryPerfect938 · 2022-09-18 09:50
i should have specified that user4 is not admin user. in my configuration i can only access point - though admin user (not root user, just user with sudo privileges, cause i guess it's more secure this way) , so yea /ssh:adminuser@ipaddress should work. however if i do \`ssh user4@ipadress\` i get Permission denied.
> For each service i made a separate user
user4 is just one of those "service users"
Sorry i'm really bad at explaining stuff ):
7890yuiop · 2022-09-18 14:43
> Tho i dont understand why i need to retype ipaddress a second time, thats pretty cumbersome.
If you're using a version of Emacs older than 27.1, failing to explicitly specify the remote hostname for each hop will cause bad behaviours that you don't want (`sudo:user4@localhost:` would get proxied to your `ipaddress` host -- a problem which is worse if, instead of `user4`, it's `root` and `sudo::`).
That got fixed, so if you're using Emacs 27.1 or later then I think you can safely use this:
/ssh:ipaddress|sudo:user4@:
mmaug · 2022-09-18 14:54
Eshell doesn't support the shell pipe (|)
BlackberryPerfect938 · 2022-09-18 14:58
Wow it DID get fixed! nice :)
BlackberryPerfect938 · 2022-09-18 15:02
Oh that's unfortunate ):
I did test `*ls | *grep pattern` and `ls | grep patter` and both worked so it seemed to me like pipes did work in eshell. I guess pipes are just not fully functional in eshell?