I f-ed up my .bashrc on a remote server and couldn't log in since ssh always starts bash before doing anything else.

I tried everything... ssh -t, scp, sshfs, sftp, but nothing worked...

I thought I was going to have to contact the server admin to get it fixed. But then by chance I stumbled across this brilliant idea:

It took a few tries to get the timing right, but pressing Ctrl-C *just* as you log in actually works!

· · Web · 2 · 2 · 6

@a did you scroll further down and look at this?

{ echo ^C; cat /dev/tty; } | ssh -tt user@host

@a instead of logging in interactively, you can also follow the ssh command with commands you want to run on the remote server.

@corburn the problem is that ssh starts the bash shell before running any other commands, so that idea doesn't work

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!