Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm SSHing a server (I'm on cygwin using openSSH), and I went into authorized_keys and modified the file as follows: ssh-rsa [key] to command="echo Working" ssh-rsa [key]

Now when I connect to the server I get the output working but then right after that I get "Connection to [server name] closed."

Why does the connection close? Did I do something wrong, or does the server somehow not allow forced commands?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You're replacing whatever shell you'd usually start by that command. So it actually behaves exactly as configured: Connect, authenticate, run the echo command, and exit.

This is supposed to be used to trigger e.g. automated jobs like backups when using a certain key to authenticate, where the connection is closed after the program call returns.

share|improve this answer
    
So if I wanted to run that command and stay connected after, what part of the command would I change? I wanted to run a startup script and stay connected, the echo Working was just for test purposes. –  gsingh2011 Oct 1 '11 at 18:32
    
@gsingh2011 You could try to run echo Working ; bash or echo Working && bash to launch a bash shell explicitly. I'm not sure it'll work though. –  Daniel Beck Oct 1 '11 at 18:33
    
echo Working ; bash worked correctly. Learned something new today :) –  gsingh2011 Oct 3 '11 at 2:46

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.