I/O Redirection - Linux

Table of Contents

user=user
hostname=ip
port=22011
scp -P $port ~/.ssh/id_rsa.pub $user@$hostname:~/.ssh/
ssh -p $port $user@$hostname "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys"

這段是一段簡易的製作ssh免密碼登入的shell,
但是 當第一次建立的時候,4 跟 5的程式碼,每次都要輸入密碼。

想請問是否有方式可以直接 cat ~/.ssh/id_rsa.pub 然後Redirection 到遠端的檔案?


--

All Comments

Michael avatarMichael2013-04-27
有現成的 ssh-copy-id
Necoo avatarNecoo2013-04-30
用expect處理密碼部份也可以