2

If I'm connecting to an ssh server and I noticed I made a mistake in the username, how do I cancel the session when the server is prompting me for password?

The only way I know is to press ctrl+c to kill the ssh process, is there a better way?

I don't necessarily need to cancel the session, just change the username.

4 Answers 4

7

You can't.

Come 'on, I mean really - just do it again - it's really not that bad. =)

1
  • haha, alright. I just thought I might be missing something obvious.
    – hasen
    May 28, 2009 at 17:35
3

Don't type the username to begin with. Just type the hostname. If your username is different on the remote host, put the username in your .ssh/config like so.

Host hostname
User remote_username

While you're at it, configure ssh keys so you don't have to put in your password.

1

I'm pretty sure there isn't a way to do that. If you feel masochistic and launch the sshd daemon on the server side in userspace with debug logging turned on, you'll see it. I don't have any log examples to hand, but what it does is take the username and anything after that is used to authenticate the username. The only way to change the username is to terminate the session and reconnect. You only get one shot per session.

1

Changing username during the authentication phase is not supported in anything less than SSH 2. Most SSH clients however do not support this feature of the protocol (I have yet to find one that actually does).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .