你可能已經在虛擬機中安裝好了交叉編譯工具鏈,但是平時的主要工作環境還是在windows下,那麼你很可能需要在windows下安裝一個xshell或者secureCRT才進行遠程登錄到虛擬機,就不用來來回回的切換了。
到此之前,可參考我的其他文章。
1. openssh-server 服務器安裝
1. 查看是否已安裝 openssh
#dpkg -l | grep ssh
2. 安裝 openssh
#apt-get install openssh-server
#apt-get install openssh-client
3. 啓動 openssh
#sudo /etc/init.d/ssh start
#sudo /etc/init.d/ssh stop
#sudo /etc/init.d/ssh restart
4. 查看22端口是否開放
#netstat -tnl
5. 查看ssh服務是否啓動
#systemctl status sshd.service
2. sshd 服務器配置
/etc/ssh/sshd_config
PasswordAuthentication yes
3. 採用public key登錄遠程服務器
1. 生成一個公鑰/私鑰對
公鑰和私鑰的就好比鎖和鑰匙的關係。
openssh的ssh-keygen命令用來產生這樣的私鑰和公鑰。
# ssh-keygen -b 1024 -t dsa -C [email protected]
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
71:e5:cb:15:d3:8c:05:ed:05:84:85:32:ce:b1:31:ce [email protected]
說明:
-b 1024 採用長度爲1024字節的公鑰/私鑰對,最長4096字節,一般1024或2048就可以了,太長的話加密解密需要的時間也長。
-t dsa 採用dsa加密方式的公鑰/私鑰對,除了dsa還有rsa方式,rsa方式最短不能小於768字節長度。
-C [email protected] 對這個公鑰/私鑰對的一個註釋和說明,一般用所有人的郵件代替。可以省略不寫
把生成的公鑰發送到對方的主機上去,用ssh-copy-id命令,自動保存在對方主機的/root/.ssh/authorized_keys 文件中去
# ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]