這個ssh指令是什麼意思?

這個ssh指令是什麼意思?

這是我從有關連接埠轉送的問題中得到的答案,但我不確定這意味著什麼。

$ ssh lab_desktop -L 2200:lab_server:22 -vvv

我的瘋狂猜測:

首先連接到lab_desktop,然後再次登入lab_server(連接埠22),從此連線接收到的資料將轉送至lab_desktop的連接埠2200。

我的瘋狂猜測是對的嗎?

但我還是不明白「-vvv」是什麼意思......


應用答案後更新:

同意小溪的有用答案和評論,我已盡力使小溪的答案發揮作用

再次讓我澄清一下術語

mypc- 負責所有打字的人

lab_desktop- ssh伺服器

lab_server- 我想要溝通的最終目的地。此伺服器僅允許來自 的連線lab_desktop。還有一件事:它只允許透過連接埠 122 進行連接。

好的,因為登入lab_desktoplab_server需要使用者名稱和密碼,所以我只是進行了 rsa 身份驗證mypc——lab_desktop 並且lab_desktop——lab_server這樣我就不會一直面臨輸入密碼的麻煩,並且只是為了留出輸入密碼的可能性,從而使ssh指令比較複雜。

之後我使用了指令:

ssh Black@lab_desktop -v -L 2200:lab_server:122

下面是輸出

chulhyun@chulhyun-Inspiron-3420:~/.ssh$ ssh Black@$labcom -v -L 2200:143.248.146.204:122 
OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 143.248.143.198 [143.248.143.198] port 22.
debug1: Connection established.
debug1: identity file /home/chulhyun/.ssh/id_rsa type -1
debug1: identity file /home/chulhyun/.ssh/id_rsa-cert type -1
debug1: identity file /home/chulhyun/.ssh/id_dsa type -1
debug1: identity file /home/chulhyun/.ssh/id_dsa-cert type -1
debug1: identity file /home/chulhyun/.ssh/id_ecdsa type -1
debug1: identity file /home/chulhyun/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 79:64:5d:e7:ac:78:b7:52:3d:9a:6a:3b:c1:37:a0:2d
debug1: Host '143.248.143.198' is known and matches the ECDSA host key.
debug1: Found key in /home/chulhyun/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/chulhyun/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to 143.248.143.198 ([143.248.143.198]:22).
debug1: Local connections to LOCALHOST:2200 forwarded to remote address 143.248.146.204:122
debug1: Local forwarding listening on ::1 port 2200.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 2200.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = ko_KR.UTF-8
Last login: Tue Jun 24 16:47:27 2014 from 143.248.244.12

Black@Black-PC ~
$

它很長,但我想我唯一應該看的是這些行:

debug1: Local connections to LOCALHOST:2200 forwarded to remote address 143.248.146.204:122
debug1: Local forwarding listening on ::1 port 2200.

當我使用 netstat 來查看這是否為 true( netstat -tulpn | grep 2200) 時,輸出為:

root@chulhyun-Inspiron-3420:/etc/ssh# netstat -tulpn | grep 2200
tcp        0      0 127.0.0.1:2200          0.0.0.0:*               LISTEN      14966/ssh       
tcp6       0      0 ::1:2200                :::*                    LISTEN      14966/ssh 

所以我想 ssh 跳躍畢竟已經建立了..

現在的問題是當我嘗試在mypc.正如 Creek 所建議的,我需要利用這個端口,所以我嘗試使用 root 帳戶和用戶帳戶登錄,但結果由於密碼而失敗。

chulhyun@chulhyun-Inspiron-3420:~$ su
password: 
root@chulhyun-Inspiron-3420:/home/chulhyun# ssh root@localhost -p 2200
root@localhost's password: 
Permission denied, please try again.
root@localhost's password: 

root@chulhyun-Inspiron-3420:/home/chulhyun# exit
exit
chulhyun@chulhyun-Inspiron-3420:~$ ssh chulhyun@localhost -p 2200
chulhyun@localhost's password: 
Permission denied, please try again.

我確信密碼是正確的。但我不明白為什麼它不起作用......

我到了這一點。您能幫助我們走得更遠嗎?


更新

我面臨的新問題在以下位置討論和解決:Linux 在 ssh 時無法辨識正確的密碼?

答案1

ssh lab_desktop -L 2200:lab_server:22 -vvv

  1. ssh lab_desktoplab_desktop- 建立到as 的ssh 連接$USER
  2. -L 2200:lab_server:22- 使用到的連接lab_desktop,將本機電腦上的連接埠 2200 轉送到 上的連接埠 22lab_server
  3. -vvv- 啟用最大詳細級別

此命令將在本機電腦上的連接埠 2200 上開啟一個套接字,然後使用 SSH 隧道,發送到本機上的連接埠 2200 的所有流量將轉送至 lab_server 上的連接埠 22。

要利用轉送的連接埠並建立與 lab_server 的 SSH 連接,您需要啟動第二個連接,以連接到 localhost 上的本機連接埠:

ssh user@localhost -p 2200

答案2

ssh -L 2200:lab_server:22 -vvv lab_desktop

將執行以下操作:

它在最高級別 (3) 上非常詳細,這意味著它將列印debug level 3資訊。一個例子是:

debug3: channel 0: will not send data after close

它允許您透過您這邊的-L給定連接埠將資料隧道傳輸到on 連接埠。2200lab_desktoplab_server22

因此,如果您連接到lab_desktopon 端口2200,您將從lab_serveron 端口接收資料22

關於 ssh 連接埠轉送的一個很好的來源是這裡

答案3

相關內容