bash OSX Terminal.app SSH 端口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14716816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
OSX Terminal.app SSH port
提问by philwinkle
I feel like a complete dunce - but I cannot seem to connect with Terminal.app and SSH to a non-standard SSH port. I'm on Mountain Lion.
我觉得自己像个傻瓜 - 但我似乎无法将 Terminal.app 和 SSH 连接到非标准 SSH 端口。我在山狮。
I've tried all of the following:
我已经尝试了以下所有方法:
$ ssh [email protected] -p 42586
$ ssh [email protected] -p42586
$ ssh -p 42586 [email protected]
$ ssh -p42586 [email protected]
I cannot seem to get the syntax right, all of the above produce an error. What is the correct order of flags? I have checked the manpage and it shows it as preceding the [user]@[domain] section, however, this throws an error as well.
我似乎无法正确使用语法,以上所有内容都会产生错误。标志的正确顺序是什么?我检查了该man页面,它显示在 [user]@[domain] 部分之前,但是,这也会引发错误。
Edit:
编辑:
More information and raw terminal output:
更多信息和原始终端输出:
$ ssh mysite.com -p42586
--hangs--
$ ssh mysite.com -p 42586
--hangs--
$ ssh -p42586 mysite.com
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-e escape_char] [-F configfile]
[-I pkcs11] [-i identity_file]
[-L [bind_address:]port:host:hostport]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R [bind_address:]port:host:hostport] [-S ctl_path]
[-W host:port] [-w local_tun[:remote_tun]]
[user@]hostname [command]
$ ssh -p 42586 mysite.com
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
/usr/bin/ssh: option requires an argument -- p
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-e escape_char] [-F configfile]
[-I pkcs11] [-i identity_file]
[-L [bind_address:]port:host:hostport]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R [bind_address:]port:host:hostport] [-S ctl_path]
[-W host:port] [-w local_tun[:remote_tun]]
[user@]hostname [command]
Examples 1 and 2 hang until timeout. 3 and 4 produce a grep usage echo as well as an ssh usage echo.
示例 1 和示例 2 挂起直到超时。3 和 4 产生一个 grep 用法回声以及一个 ssh 用法回声。
Edit 2:
编辑2:
Thanks for the suggestion @topguncoder my original attempt was the colon notation - but that produces a different error:
感谢@topguncoder 的建议,我最初的尝试是使用冒号符号 - 但这会产生不同的错误:
$ ssh [email protected]:42586
ssh: Could not resolve hostname mysite:42586: nodename nor servname provided, or not known
回答by nneonneo
Try
尝试
"ssh" -p 42586 mysite.com
to ignore your aliassettings. It looks like you might have sshaliased to something else. If this works, you should check your .profilefor any sshaliases.
忽略您的alias设置。看起来您可能已ssh别名为其他内容。如果这有效,您应该检查您.profile的任何ssh别名。
回答by Hai Vu
I believe that on your system, the sshcommand somehow was redefined as the grepcommand. Try this:
我相信在你的系统上,ssh命令以某种方式被重新定义为grep命令。尝试这个:
alias | /usr/bin/grep ssh
What do you see? Also, try this:
你看到了什么?另外,试试这个:
/usr/bin/ssh -p 42586 [email protected]
Do you have a success connection? If ssh was aliased into something else. Check the following files:
你有成功的连接吗?如果 ssh 别名为其他内容。检查以下文件:
- ~/.bash_profile
- ~/.bashrc
- ~/.profile
- ~/.bash_profile
- ~/.bashrc
- ~/.profile
You can then remove the alias, or use the absolute path (e.g /usr/bin/ssh)
然后您可以删除别名,或使用绝对路径(例如/usr/bin/ssh)

