Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

up vote 7 down vote accepted

You can't.

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

share|improve this answer
    
haha, alright. I just thought I might be missing something obvious. –  hasenj May 28 '09 at 17:35

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.

share|improve this answer

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).

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.