sshã§å¤æ®µæ¥ç¶ (ncã-Wããªã人ç¨)
sshã§å¤æ®µæ¥ç¶ããããå¤æ®µæ¥ç¶ã«ã¤ãã¦ä¸çªãããæãã¾ã¨ã¾ã£ã¦ããµã¤ãã¯
ncããéãã¼ãã¯ã©ãã¾ã§ã§ãããããï¼
ã ã¨æãããã æ®å¿µãªãã¨ã«ããã¡ã®ç°å¢ã«ã¯ nc
ãå
¥ã£ã¦ãªãã£ãã
$ ssh remote bash: nc: command not found ssh_exchange_identification: Connection closed by remote host
æè¿ã¯ nc
ã使ããã« ssh -W
ãªãã·ã§ã³ã§ä»£ç¨ã§ãããããã
ä»å¾ã¯ãã¡ããæ¨å¥¨ãããã¨ã®ãã¨ã
ProxyCommandã«ããsshã®å¤æ®µæ¥ç¶ã«ã¤ãã¦
ãããåã®ç°å¢ã«ã¯ssh -W
ããªãã£ãããã¦ã©ããããã
connect ã®å°å ¥
ããããã¨ã㯠connect
ã使ãã
connect ã使ã£ã¦ç°¡åã«å¤æ®µ SSH ãå®ç¾ããæ¹æ³
ã«ãã®ã¸ãã®äºæ
ãè¼ã£ã¦ããã
connect
ã³ãã³ãã®å°å
¥ã¯ã¨ã¦ãç°¡åã§ã
connect.c
ã ä¸ç¶å°ã« ãã¦ã³ãã¼ãããå¾ã
$ gcc connect.c -o connect
ã§ã³ã³ãã¤ã«ããã°ãããã
ç°å¢è¨å®
local
ãããä¸ç¶å°step
ãçµç±ãã¦ãremote
ã«æ¥ç¶ãããã
ãã£ããæ¸ãããã©ãä¸ç¶å°ã« connect
ãå°å
¥ãããã¨ã
local -----------> step -----------> remote âconnectå°å ¥
localã®ç°å¢
localã§ã¯~/.ssh/config
ã ãè¨å®ã
# local (~/.ssh/config) Host remote Hostname remote.url.jp # remoteã®url ProxyCommand ssh step /home/step/bin/connect %h %p # âstepãµã¼ãã¼å ã§ã®connectãã¹ãæå® User remote_account_name # stepããremoteã«æ¥ç¶ããã¨ãã®ã¢ã«ã¦ã³ãå # --------------- Host step Hostname step.url.jp # stepã®url User step_account_name # localããstepã«æ¥ç¶ããã¨ãã®ã¢ã«ã¦ã³ãå
stepã®ç°å¢
stepã§ã¯~/.ssh/config
ã¨~/.ssh/authorized_keys
ãè¨å®ã
ã¾ã~/.ssh/config
# step (~/.ssh/config) Host remote Hostname remote.url.jp # remoteã®url User remote_account_name # stepããremoteã«æ¥ç¶ããã¨ãã®ã¢ã«ã¦ã³ãå
.ssh/authorized_keys
# step (~/.ssh/authorized_keys) localã®~/.ssh/id_rsa.pubãç»é²
remoteã®ç°å¢
remoteã§ã¯~/.ssh/authorized_keys
ãè¨å®ã
# remote (~/.ssh/authorized_keys) stepã®~/.ssh/id_rsa.pubãç»é² localã®~/.ssh/id_rsa.pubãç»é²