Ssh – commands in authorized_keys


I've created an SSH non root/non super user with an authorized_key to remotely login to my server and shut it down however, i'm trying to do this from within the authorized_key file by using the command="" syntax

I have the following in the authorized_keys file

command="shutdown -p now",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa 

However when trying to execute the ssh login, while the user is able to login….the command doesn't seem to be executed.

What is the correct syntax for commands when being used in the authorized_keys?

how does no-port-forwarding,no-x11-forwarding,…etc affect the user's ability to login with the command remotely?

the command

/usr/bin/ssh -2 -i /path/to/.ssh/rsa -p 22 -vvv -l user

debug information

debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp 
debug3: sign_and_send_pubkey: RSA 
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Saving password to keychain failed
debug3: Incorrect RSA1 identifier
debug1: read PEM private key done: type RSA
Identity added: /.... //removed
(/.../.ssh/shutdown_rsa) // removed 
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to ([]:22). //removed
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting
debug1: Entering interactive session.
debug1: client_input_global_request: rtype want_reply 0
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug3: Ignored env TERM_PROGRAM
debug3: Ignored env SHELL
debug3: Ignored env TERM
debug3: Ignored env TMPDIR
debug3: Ignored env Apple_PubSub_Socket_Render
debug3: Ignored env TERM_PROGRAM_VERSION
debug3: Ignored env TERM_SESSION_ID
debug3: Ignored env USER
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env __CF_USER_TEXT_ENCODING
debug3: Ignored env PATH
debug3: Ignored env PWD
debug3: Ignored env XPC_FLAGS
debug3: Ignored env XPC_SERVICE_NAME
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug1: Sending env LC_CTYPE = UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env DISPLAY
debug3: Ignored env SECURITYSESSIONID
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug2: callback done

Best Answer

Directive "command" in autorhized_keys DOES NOT executes specified command it only allows user to run this particular command remontly using this key.