How to ssh as another user

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

2 Answers

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.

0

Does setting the -l flag not work?

i.e. $ ssh host -l username

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like