{"action":"created","issue":{"url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/issues/1082","repository_url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH","labels_url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/issues/1082/labels{/name}","comments_url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/issues/1082/comments","events_url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/issues/1082/events","html_url":"https://github.com/PowerShell/Win32-OpenSSH/issues/1082","id":299516045,"node_id":"MDU6SXNzdWUyOTk1MTYwNDU=","number":1082,"title":"Remote SSH commands require double escaping before hitting the DefaultShell","user":{"login":"penguin359","id":876348,"node_id":"MDQ6VXNlcjg3NjM0OA==","avatar_url":"https://avatars3.githubusercontent.com/u/876348?v=4","gravatar_id":"","url":"https://api.github.com/users/penguin359","html_url":"https://github.com/penguin359","followers_url":"https://api.github.com/users/penguin359/followers","following_url":"https://api.github.com/users/penguin359/following{/other_user}","gists_url":"https://api.github.com/users/penguin359/gists{/gist_id}","starred_url":"https://api.github.com/users/penguin359/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penguin359/subscriptions","organizations_url":"https://api.github.com/users/penguin359/orgs","repos_url":"https://api.github.com/users/penguin359/repos","events_url":"https://api.github.com/users/penguin359/events{/privacy}","received_events_url":"https://api.github.com/users/penguin359/received_events","type":"User","site_admin":false},"labels":[{"id":333022707,"node_id":"MDU6TGFiZWwzMzMwMjI3MDc=","url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/labels/Area-Terminal%20experience","name":"Area-Terminal experience","color":"5319e7","default":false},{"id":257862387,"node_id":"MDU6TGFiZWwyNTc4NjIzODc=","url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/labels/Issue-Bug","name":"Issue-Bug","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":{"login":"bingbing8","id":12284203,"node_id":"MDQ6VXNlcjEyMjg0MjAz","avatar_url":"https://avatars0.githubusercontent.com/u/12284203?v=4","gravatar_id":"","url":"https://api.github.com/users/bingbing8","html_url":"https://github.com/bingbing8","followers_url":"https://api.github.com/users/bingbing8/followers","following_url":"https://api.github.com/users/bingbing8/following{/other_user}","gists_url":"https://api.github.com/users/bingbing8/gists{/gist_id}","starred_url":"https://api.github.com/users/bingbing8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bingbing8/subscriptions","organizations_url":"https://api.github.com/users/bingbing8/orgs","repos_url":"https://api.github.com/users/bingbing8/repos","events_url":"https://api.github.com/users/bingbing8/events{/privacy}","received_events_url":"https://api.github.com/users/bingbing8/received_events","type":"User","site_admin":false},"assignees":[{"login":"bingbing8","id":12284203,"node_id":"MDQ6VXNlcjEyMjg0MjAz","avatar_url":"https://avatars0.githubusercontent.com/u/12284203?v=4","gravatar_id":"","url":"https://api.github.com/users/bingbing8","html_url":"https://github.com/bingbing8","followers_url":"https://api.github.com/users/bingbing8/followers","following_url":"https://api.github.com/users/bingbing8/following{/other_user}","gists_url":"https://api.github.com/users/bingbing8/gists{/gist_id}","starred_url":"https://api.github.com/users/bingbing8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bingbing8/subscriptions","organizations_url":"https://api.github.com/users/bingbing8/orgs","repos_url":"https://api.github.com/users/bingbing8/repos","events_url":"https://api.github.com/users/bingbing8/events{/privacy}","received_events_url":"https://api.github.com/users/bingbing8/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/milestones/40","html_url":"https://github.com/PowerShell/Win32-OpenSSH/milestone/40","labels_url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/milestones/40/labels","id":3526302,"node_id":"MDk6TWlsZXN0b25lMzUyNjMwMg==","number":40,"title":"vNext","description":"","creator":{"login":"bingbing8","id":12284203,"node_id":"MDQ6VXNlcjEyMjg0MjAz","avatar_url":"https://avatars0.githubusercontent.com/u/12284203?v=4","gravatar_id":"","url":"https://api.github.com/users/bingbing8","html_url":"https://github.com/bingbing8","followers_url":"https://api.github.com/users/bingbing8/followers","following_url":"https://api.github.com/users/bingbing8/following{/other_user}","gists_url":"https://api.github.com/users/bingbing8/gists{/gist_id}","starred_url":"https://api.github.com/users/bingbing8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bingbing8/subscriptions","organizations_url":"https://api.github.com/users/bingbing8/orgs","repos_url":"https://api.github.com/users/bingbing8/repos","events_url":"https://api.github.com/users/bingbing8/events{/privacy}","received_events_url":"https://api.github.com/users/bingbing8/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":2,"state":"open","created_at":"2018-07-26T18:57:07Z","updated_at":"2018-10-09T05:19:06Z","due_on":null,"closed_at":null},"comments":20,"created_at":"2018-02-22T21:33:11Z","updated_at":"2018-10-23T17:34:46Z","closed_at":null,"author_association":"NONE","body":"**\"OpenSSH for Windows\" version**\r\n1.0.0.0\r\n \r\n**Server OperatingSystem**\r\nWindows Server 2016 Standard\r\n\r\n**Client OperatingSystem**\r\nFedora 27\r\n\r\n**What is failing**\r\nAttempting to run remote commands using SSH with my DefaultShell set to powershell.exe requires escaping the command to pass through both my local shell and the Command Prompt on the remote Windows server before PowerShell handles the command. As a simple example, this is the command as run directly inside Powershell:\r\n\r\necho \"\\`\"hello\\`\"\"\r\n\r\nWhich produces this output:\r\n\"hello\"\r\n\r\nAttempting to run the above command from a Bash script on Linux, I expect to have to use single quotes around the command to avoid Bash interpresting the double-quotes and back-ticks, but not much else:\r\n\r\nssh windows 'echo \"\\`\"hello\\`\"\"'\r\n\r\nIt's hard to read, but that ends in back-tick, double-quote, double-quote, single-quote. However, I find that this only produces the following output:\r\nhello`\r\n\r\nWhich seems to be due to the Command Prompt first interpreting the double-quotes before handing it off to PowerShell. Instead, I must quote the command for the Command Prompt and then for Bash in order for it to pass all the way to PowerShell unencumbered. The following command produces the correct output:\r\n\r\nssh windows '\"echo \\\\\"\\`\\\\\"hello\\`\\\\\"\\\\\"\"'\r\n\r\nThis is far from intuitive and gets worse as I try to do more complex commands including pipes, where-object and foreach-object using the ?, %, and {} metacharacters.\r\n\r\n**Expected output**\r\n\"hello\"\r\n\r\n**Actual output**\r\nhello\\`"},"comment":{"url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/issues/comments/432344702","html_url":"https://github.com/PowerShell/Win32-OpenSSH/issues/1082#issuecomment-432344702","issue_url":"https://api.github.com/repos/PowerShell/Win32-OpenSSH/issues/1082","id":432344702,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjM0NDcwMg==","user":{"login":"bingbing8","id":12284203,"node_id":"MDQ6VXNlcjEyMjg0MjAz","avatar_url":"https://avatars0.githubusercontent.com/u/12284203?v=4","gravatar_id":"","url":"https://api.github.com/users/bingbing8","html_url":"https://github.com/bingbing8","followers_url":"https://api.github.com/users/bingbing8/followers","following_url":"https://api.github.com/users/bingbing8/following{/other_user}","gists_url":"https://api.github.com/users/bingbing8/gists{/gist_id}","starred_url":"https://api.github.com/users/bingbing8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bingbing8/subscriptions","organizations_url":"https://api.github.com/users/bingbing8/orgs","repos_url":"https://api.github.com/users/bingbing8/repos","events_url":"https://api.github.com/users/bingbing8/events{/privacy}","received_events_url":"https://api.github.com/users/bingbing8/received_events","type":"User","site_admin":false},"created_at":"2018-10-23T17:34:46Z","updated_at":"2018-10-23T17:34:46Z","author_association":"COLLABORATOR","body":"@manojampalam , we had the similar discussion in https://github.com/PowerShell/Win32-OpenSSH/issues/1273.  there is quotes rule for cmd. \r\nIf /C or /K is specified, then the remainder of the command line after\r\nthe switch is processed as a command line, where the following logic is\r\nused to process quote (\") characters:\r\n\r\n    1.  If all of the following conditions are met, then quote characters\r\n        on the command line are preserved:\r\n\r\n        - no /S switch\r\n        - exactly two quote characters\r\n        - no special characters between the two quote characters,\r\n          where special is one of: &<>()@^|\r\n        - there are one or more whitespace characters between the\r\n          two quote characters\r\n        - the string between the two quote characters is the name\r\n          of an executable file.\r\n\r\n    2.  Otherwise, old behavior is to see if the first character is\r\n        a quote character and if so, strip the leading character and\r\n        remove the last quote character on the command line, preserving\r\n        any text after the last quote character."}}
{"actor":{"display_login":"bingbing8"}}