How to ssh as another user
Solution 1
What I am going to do is create an account X on my local computer. Login as account X, then ssh-keygen for account X.
No, what you're going to do is rather useless. The server doesn't know anything about your local account name (like it used to in the rsh days); the ssh
client merely uses it as the default login name it'll try, and the ssh-keygen
tool merely puts it in the "comment" field which isn't used for anything at all.
If you want to log in to the server as account X, just ask ssh
to do so:
ssh X@myserver
This will make the server check your password or pubkey against the remote user X
's information.
Solution 2
Does setting the -l flag not work?
i.e. $ ssh host -l username
chipbk10
Updated on September 18, 2022Comments
-
chipbk10 almost 2 years
The remote server only allows account X to ssh to. Now, from my computer, I want to ssh to the remote server as account X without password. I generate the private key on my local computer and share the public key to the remote server as the tutorial
However, the private key and public key are only applied for my account. Is it possible to make these keys as account X ?
What I am going to do is create an account X on my local computer. Login as account X, then ssh-keygen for account X.
Note: my computer is Mac, my server is Linux
-
DavidPostill about 8 yearsThis is really a comment and not an answer to the original question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?