遠程命令執行
遠程文件傳輸
遺憾的事情是:這些操作不安全!
使用純文本口令,并用明文發送
信息可能會被截取,口令可能會被檢索
未經授權的人員使用截取的口令登陸系統而對系統造成危害
在日常操作練習時,用ssh登錄其他主機時,可能會每次都需要輸入登錄密碼,哪怕用scp復制東西也需要。
為了更方便快捷的切換主機,ssh免密通信不失為更好的選擇;
用ssh-keygen生成密鑰,默認保存在本地的/root/.ssh/id_rsa
然后在用ssh-copy-id分發至目標主機之上;登錄用戶@主機名或IP地址
注意:
1.最好是用主機名,在/etc/hosts文件中寫入主機名和對應的IP地址;
2.免密通信需要雙方相互認證,所以也需要在目標主機對本機做一次相同的操作;
[root@www ~]# ssh-keygen -t rsa -P \\\'\\\' Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists. Overwrite (y/n)?
[root@www ~]#ssh-copy-id -i .ssh/id_rsa.pub root@172.16.75.1 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: .ssh/id_rsa.pub The authenticity of host \\\'172.16.75.1 (172.16.75.1)\\\' can\\\'t be established. ECDSA key fingerprint is SHA256:YXhbTS9MfK2IQC4gtOW4RL8voHvFqC1cAAMJXuF3Wec. ECDSA key fingerprint is MD5:2c:c0:94:e8:3a:e4:74:88:c0:d8:e0:01:20:81:1d:8e. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@172.16.75.1\\\'s Number of key(s) added: 1 Now try logging into the machine, with: ssh \\\'root@172.16.75.1\\\' and check to make sure that only the key(s) you wanted were added.
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持三五互聯。
更多關于云服務器,域名注冊,虛擬主機的問題,請訪問三五互聯官網:m.shinetop.cn