{"action":"created","comment":{"url":"https://api.github.com/repos/docker/machine/pulls/comments/76782740","id":76782740,"diff_hunk":"@@ -148,6 +150,11 @@ func getInfoForScpArg(hostAndPath string, hostInfoLoader HostInfoLoader) (HostIn\n \t}\n \n \targs := []string{}\n+\tport, err := hostInfo.GetSSHPort()\n+\tif err == nil && port > 0 {\n+\t\targs = append(args, \"-P\", fmt.Sprintf(\"%v\", port))\n+\t}","path":"commands/scp.go","position":16,"original_position":16,"commit_id":"5ce0ab2d12aec5b9128d6ac6575c04e73552029d","original_commit_id":"5ce0ab2d12aec5b9128d6ac6575c04e73552029d","user":{"login":"twang2218","id":6299096,"avatar_url":"https://avatars.githubusercontent.com/u/6299096?v=3","gravatar_id":"","url":"https://api.github.com/users/twang2218","html_url":"https://github.com/twang2218","followers_url":"https://api.github.com/users/twang2218/followers","following_url":"https://api.github.com/users/twang2218/following{/other_user}","gists_url":"https://api.github.com/users/twang2218/gists{/gist_id}","starred_url":"https://api.github.com/users/twang2218/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twang2218/subscriptions","organizations_url":"https://api.github.com/users/twang2218/orgs","repos_url":"https://api.github.com/users/twang2218/repos","events_url":"https://api.github.com/users/twang2218/events{/privacy}","received_events_url":"https://api.github.com/users/twang2218/received_events","type":"User","site_admin":false},"body":"I saw the blog, and tried without success. I don't think `-P` works for the multi remote host with different ports. Here is what I tried, with the debug turned on.\r\n\r\nIf I put the both `-P` at beginning, it seems only the last one works.\r\n\r\n```bash\r\nroot@d2:~# scp -v -P 231 -P 232 root@138.68.61.69:./README.md root@138.68.50.80:./\r\nExecuting: /usr/bin/ssh '-x' '-oClearAllForwardings=yes' '-n' '-v' '-p' '231' '-p' '232' '-l' 'root' '--' '138.68.61.69' 'scp -v' './README.md' 'root@138.68.50.80:./'\r\nOpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g-fips  1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: /etc/ssh/ssh_config line 59: Applying options for *\r\ndebug1: Connecting to 138.68.61.69 [138.68.61.69] port 232.\r\ndebug1: connect to address 138.68.61.69 port 232: Connection refused\r\nssh: connect to host 138.68.61.69 port 232: Connection refused\r\n```\r\n\r\nIf I put `-P` in front of each server, only the first server is ok to connect.\r\n\r\n```bash\r\nroot@d2:~# scp -v -P 231 root@138.68.61.69:./README.md -P 232 root@138.68.50.80:./\r\nExecuting: /usr/bin/ssh '-x' '-oClearAllForwardings=yes' '-n' '-v' '-p' '231' '-l' 'root' '--' '138.68.61.69' 'scp -v -d' './README.md' 'root@138.68.50.80:./'\r\nOpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g-fips  1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: /etc/ssh/ssh_config line 59: Applying options for *\r\ndebug1: Connecting to 138.68.61.69 [138.68.61.69] port 231.\r\ndebug1: Connection established.\r\ndebug1: permanently_set_uid: 0/0\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_rsa type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_rsa-cert type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_dsa type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_dsa-cert type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_ecdsa type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_ecdsa-cert type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_ed25519 type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /root/.ssh/id_ed25519-cert type -1\r\ndebug1: Enabling compatibility mode for protocol 2.0\r\ndebug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1\r\ndebug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1\r\ndebug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000\r\ndebug1: Authenticating to 138.68.61.69:231 as 'root'\r\ndebug1: SSH2_MSG_KEXINIT sent\r\ndebug1: SSH2_MSG_KEXINIT received\r\ndebug1: kex: algorithm: curve25519-sha256@libssh.org\r\ndebug1: kex: host key algorithm: ecdsa-sha2-nistp256\r\ndebug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r\ndebug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r\ndebug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r\ndebug1: Server host key: ecdsa-sha2-nistp256 SHA256:Y+0bgv/+1MhjHkZ7QX9TNMSfZMd1NMUsAvDKN0IB24Q\r\ndebug1: Host '[138.68.61.69]:231' is known and matches the ECDSA host key.\r\ndebug1: Found key in /root/.ssh/known_hosts:1\r\ndebug1: rekey after 134217728 blocks\r\ndebug1: SSH2_MSG_NEWKEYS sent\r\ndebug1: expecting SSH2_MSG_NEWKEYS\r\ndebug1: rekey after 134217728 blocks\r\ndebug1: SSH2_MSG_NEWKEYS received\r\ndebug1: SSH2_MSG_EXT_INFO received\r\ndebug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>\r\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\r\ndebug1: Authentications that can continue: publickey,password\r\ndebug1: Next authentication method: publickey\r\ndebug1: Trying private key: /root/.ssh/id_rsa\r\ndebug1: Authentication succeeded (publickey).\r\nAuthenticated to 138.68.61.69 ([138.68.61.69]:231).\r\ndebug1: channel 0: new [client-session]\r\ndebug1: Requesting no-more-sessions@openssh.com\r\ndebug1: Entering interactive session.\r\ndebug1: pledge: network\r\ndebug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0\r\ndebug1: Sending environment.\r\ndebug1: Sending env LANG = en_US.UTF-8\r\ndebug1: Sending command: scp -v -d ./README.md root@138.68.50.80:./\r\nExecuting: program /usr/bin/ssh host 138.68.50.80, user root, command scp -v -d -t ./\r\nOpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g-fips  1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: /etc/ssh/ssh_config line 59: Applying options for *\r\ndebug1: Connecting to 138.68.50.80 [138.68.50.80] port 22.\r\ndebug1: connect to address 138.68.50.80 port 22: Connection refused\r\nssh: connect to host 138.68.50.80 port 22: Connection refused\r\ndebug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r\nlost connection\r\ndebug1: channel 0: free: client-session, nchannels 1\r\nTransferred: sent 2400, received 3232 bytes, in 0.2 seconds\r\nBytes per second: sent 10566.2, received 14229.1\r\ndebug1: Exit status 1\r\nExecuting: program /usr/bin/ssh host 138.68.50.80, user root, command scp -v -d -t ./\r\nOpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g-fips  1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: /etc/ssh/ssh_config line 59: Applying options for *\r\ndebug1: Connecting to 138.68.50.80 [138.68.50.80] port 231.\r\ndebug1: connect to address 138.68.50.80 port 231: Connection refused\r\nssh: connect to host 138.68.50.80 port 231: Connection refused\r\nlost connection\r\nroot@d2:~#\r\n```\r\n","created_at":"2016-08-30T12:15:06Z","updated_at":"2016-08-30T12:15:06Z","html_url":"https://github.com/docker/machine/pull/3706#discussion_r76782740","pull_request_url":"https://api.github.com/repos/docker/machine/pulls/3706","_links":{"self":{"href":"https://api.github.com/repos/docker/machine/pulls/comments/76782740"},"html":{"href":"https://github.com/docker/machine/pull/3706#discussion_r76782740"},"pull_request":{"href":"https://api.github.com/repos/docker/machine/pulls/3706"}}},"pull_request":{"url":"https://api.github.com/repos/docker/machine/pulls/3706","id":83178479,"html_url":"https://github.com/docker/machine/pull/3706","diff_url":"https://github.com/docker/machine/pull/3706.diff","patch_url":"https://github.com/docker/machine/pull/3706.patch","issue_url":"https://api.github.com/repos/docker/machine/issues/3706","number":3706,"state":"open","locked":false,"title":"Add SSH port support for scp command. Fix #3492","user":{"login":"twang2218","id":6299096,"avatar_url":"https://avatars.githubusercontent.com/u/6299096?v=3","gravatar_id":"","url":"https://api.github.com/users/twang2218","html_url":"https://github.com/twang2218","followers_url":"https://api.github.com/users/twang2218/followers","following_url":"https://api.github.com/users/twang2218/following{/other_user}","gists_url":"https://api.github.com/users/twang2218/gists{/gist_id}","starred_url":"https://api.github.com/users/twang2218/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twang2218/subscriptions","organizations_url":"https://api.github.com/users/twang2218/orgs","repos_url":"https://api.github.com/users/twang2218/repos","events_url":"https://api.github.com/users/twang2218/events{/privacy}","received_events_url":"https://api.github.com/users/twang2218/received_events","type":"User","site_admin":false},"body":"Fix #3492\r\nSigned-off-by: Tao Wang <twang2218@gmail.com>","created_at":"2016-08-29T22:23:52Z","updated_at":"2016-08-30T12:15:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d414511462ce6309f3933f71331deb3c4db2a40e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/docker/machine/pulls/3706/commits","review_comments_url":"https://api.github.com/repos/docker/machine/pulls/3706/comments","review_comment_url":"https://api.github.com/repos/docker/machine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/machine/issues/3706/comments","statuses_url":"https://api.github.com/repos/docker/machine/statuses/5ce0ab2d12aec5b9128d6ac6575c04e73552029d","head":{"label":"twang2218:scpport","ref":"scpport","sha":"5ce0ab2d12aec5b9128d6ac6575c04e73552029d","user":{"login":"twang2218","id":6299096,"avatar_url":"https://avatars.githubusercontent.com/u/6299096?v=3","gravatar_id":"","url":"https://api.github.com/users/twang2218","html_url":"https://github.com/twang2218","followers_url":"https://api.github.com/users/twang2218/followers","following_url":"https://api.github.com/users/twang2218/following{/other_user}","gists_url":"https://api.github.com/users/twang2218/gists{/gist_id}","starred_url":"https://api.github.com/users/twang2218/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twang2218/subscriptions","organizations_url":"https://api.github.com/users/twang2218/orgs","repos_url":"https://api.github.com/users/twang2218/repos","events_url":"https://api.github.com/users/twang2218/events{/privacy}","received_events_url":"https://api.github.com/users/twang2218/received_events","type":"User","site_admin":false},"repo":{"id":66826429,"name":"machine","full_name":"twang2218/machine","owner":{"login":"twang2218","id":6299096,"avatar_url":"https://avatars.githubusercontent.com/u/6299096?v=3","gravatar_id":"","url":"https://api.github.com/users/twang2218","html_url":"https://github.com/twang2218","followers_url":"https://api.github.com/users/twang2218/followers","following_url":"https://api.github.com/users/twang2218/following{/other_user}","gists_url":"https://api.github.com/users/twang2218/gists{/gist_id}","starred_url":"https://api.github.com/users/twang2218/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twang2218/subscriptions","organizations_url":"https://api.github.com/users/twang2218/orgs","repos_url":"https://api.github.com/users/twang2218/repos","events_url":"https://api.github.com/users/twang2218/events{/privacy}","received_events_url":"https://api.github.com/users/twang2218/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/twang2218/machine","description":"Machine management for a container-centric world","fork":true,"url":"https://api.github.com/repos/twang2218/machine","forks_url":"https://api.github.com/repos/twang2218/machine/forks","keys_url":"https://api.github.com/repos/twang2218/machine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twang2218/machine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twang2218/machine/teams","hooks_url":"https://api.github.com/repos/twang2218/machine/hooks","issue_events_url":"https://api.github.com/repos/twang2218/machine/issues/events{/number}","events_url":"https://api.github.com/repos/twang2218/machine/events","assignees_url":"https://api.github.com/repos/twang2218/machine/assignees{/user}","branches_url":"https://api.github.com/repos/twang2218/machine/branches{/branch}","tags_url":"https://api.github.com/repos/twang2218/machine/tags","blobs_url":"https://api.github.com/repos/twang2218/machine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twang2218/machine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twang2218/machine/git/refs{/sha}","trees_url":"https://api.github.com/repos/twang2218/machine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twang2218/machine/statuses/{sha}","languages_url":"https://api.github.com/repos/twang2218/machine/languages","stargazers_url":"https://api.github.com/repos/twang2218/machine/stargazers","contributors_url":"https://api.github.com/repos/twang2218/machine/contributors","subscribers_url":"https://api.github.com/repos/twang2218/machine/subscribers","subscription_url":"https://api.github.com/repos/twang2218/machine/subscription","commits_url":"https://api.github.com/repos/twang2218/machine/commits{/sha}","git_commits_url":"https://api.github.com/repos/twang2218/machine/git/commits{/sha}","comments_url":"https://api.github.com/repos/twang2218/machine/comments{/number}","issue_comment_url":"https://api.github.com/repos/twang2218/machine/issues/comments{/number}","contents_url":"https://api.github.com/repos/twang2218/machine/contents/{+path}","compare_url":"https://api.github.com/repos/twang2218/machine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twang2218/machine/merges","archive_url":"https://api.github.com/repos/twang2218/machine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twang2218/machine/downloads","issues_url":"https://api.github.com/repos/twang2218/machine/issues{/number}","pulls_url":"https://api.github.com/repos/twang2218/machine/pulls{/number}","milestones_url":"https://api.github.com/repos/twang2218/machine/milestones{/number}","notifications_url":"https://api.github.com/repos/twang2218/machine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twang2218/machine/labels{/name}","releases_url":"https://api.github.com/repos/twang2218/machine/releases{/id}","deployments_url":"https://api.github.com/repos/twang2218/machine/deployments","created_at":"2016-08-29T08:39:59Z","updated_at":"2016-08-29T08:40:01Z","pushed_at":"2016-08-29T22:22:47Z","git_url":"git://github.com/twang2218/machine.git","ssh_url":"git@github.com:twang2218/machine.git","clone_url":"https://github.com/twang2218/machine.git","svn_url":"https://github.com/twang2218/machine","homepage":"https://docs.docker.com/machine/","size":15838,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"2943cdd7f3063ecabfdef0cfe716b88e3a92d738","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":27494663,"name":"machine","full_name":"docker/machine","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/machine","description":"Machine management for a container-centric world","fork":false,"url":"https://api.github.com/repos/docker/machine","forks_url":"https://api.github.com/repos/docker/machine/forks","keys_url":"https://api.github.com/repos/docker/machine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/machine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/machine/teams","hooks_url":"https://api.github.com/repos/docker/machine/hooks","issue_events_url":"https://api.github.com/repos/docker/machine/issues/events{/number}","events_url":"https://api.github.com/repos/docker/machine/events","assignees_url":"https://api.github.com/repos/docker/machine/assignees{/user}","branches_url":"https://api.github.com/repos/docker/machine/branches{/branch}","tags_url":"https://api.github.com/repos/docker/machine/tags","blobs_url":"https://api.github.com/repos/docker/machine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/machine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/machine/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/machine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/machine/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/machine/languages","stargazers_url":"https://api.github.com/repos/docker/machine/stargazers","contributors_url":"https://api.github.com/repos/docker/machine/contributors","subscribers_url":"https://api.github.com/repos/docker/machine/subscribers","subscription_url":"https://api.github.com/repos/docker/machine/subscription","commits_url":"https://api.github.com/repos/docker/machine/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/machine/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/machine/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/machine/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/machine/contents/{+path}","compare_url":"https://api.github.com/repos/docker/machine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/machine/merges","archive_url":"https://api.github.com/repos/docker/machine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/machine/downloads","issues_url":"https://api.github.com/repos/docker/machine/issues{/number}","pulls_url":"https://api.github.com/repos/docker/machine/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/machine/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/machine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/machine/labels{/name}","releases_url":"https://api.github.com/repos/docker/machine/releases{/id}","deployments_url":"https://api.github.com/repos/docker/machine/deployments","created_at":"2014-12-03T15:52:06Z","updated_at":"2016-08-30T10:14:37Z","pushed_at":"2016-08-29T22:23:53Z","git_url":"git://github.com/docker/machine.git","ssh_url":"git@github.com:docker/machine.git","clone_url":"https://github.com/docker/machine.git","svn_url":"https://github.com/docker/machine","homepage":"https://docs.docker.com/machine/","size":42045,"stargazers_count":3481,"watchers_count":3481,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":929,"mirror_url":null,"open_issues_count":531,"forks":929,"open_issues":531,"watchers":3481,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/machine/pulls/3706"},"html":{"href":"https://github.com/docker/machine/pull/3706"},"issue":{"href":"https://api.github.com/repos/docker/machine/issues/3706"},"comments":{"href":"https://api.github.com/repos/docker/machine/issues/3706/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/machine/pulls/3706/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/machine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/machine/pulls/3706/commits"},"statuses":{"href":"https://api.github.com/repos/docker/machine/statuses/5ce0ab2d12aec5b9128d6ac6575c04e73552029d"}}}}
{"actor":{"display_login":"twang2218"}}