sshd使用
| sshd服务 1.sshd介绍 ?连接方式(在客户端):ssh [email?protected]? #文本模式 ?注意: ?远程复制:? 格式 scp file [email?protected]:dir(文件的上传) ??????????????? scp [email?protected]:/dir file(文件的下载) 
 ?? [[email?protected] mnt]# ls niu/ ?? 此时可以在97主机下的桌面上看到file1:? 
  ?? [ 
 [email?protected] ~]# cd /root/Desktop/ 
  ?? [ [email?protected] Desktop]# ls ???file1 
 
  ?? [ 
 [email?protected] ~]# scp ro 
 [email?protected]:/root/Desktop/file /mnt/ 
  ??? file????????????????????????????????????????? 100%??? 0???? 0.0KB/s?? 00:00 ?? 此时可以在177主机上/mnt/目录下可以看到file文件 
  ?? [ 
 [email?protected] ~]# ls /mnt/ 
  ???file? niu? [email?protected] 2.sshd 的key认证 【1】生成认证KEY ? 生成密钥的命令:ssh-keygen 
  [ 
 [email?protected] ~]# rm -rf .ssh/ 
  [ [email?protected] ~]# ls -a .??????????????? .bash_logout?? .config??? Downloads????? Music???? Templates ..?????????????? .bash_profile? .cshrc???? .esd_auth????? Pictures? Videos anaconda-ks.cfg? .bashrc??????? Desktop??? .ICEauthority? Public??? .viminfo .bash_history??? .cache???????? Documents? .local???????? .tcshrc [ [email?protected] ~]#?ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa):? Created directory ‘/root/.ssh‘. Enter passphrase (empty for no passphrase):? Enter same passphrase again:? Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 8c:23:ee:39:11:6b:e6:af:a3:76:b1:00:a5:6e:d1:d3 [email?protected] The key‘s randomart image is: +--[ RSA 2048]----+ |???????????????? | |? .????????????? | | o. .??????????? | |o. o.E o???????? | |... ooo S??????? | | o..*. .???????? | |.? =.+?????????? | |? ..*.?????????? | | ..o+=.????????? | +-----------------+ ? 【2】加密服务? 使用命令:ssh-copy-id -i /root/.ssh/id_rsa.pub? [email?protected] 
  [ 
 [email?protected] ~]# cd .ssh/ 
  [ [email?protected] .ssh]# ls id_rsa? id_rsa.pub 
    [ 
   [email?protected] .ssh]#?ssh-copy-id -i /root/.ssh/id_rsa.pub 
   [email?protected] 
    The authenticity of host ‘172.25.254.97 (172.25.254.97)‘ can‘t be established. ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08. 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 [email?protected]‘s password:? Number of key(s) added: 1 Now try logging into the machine,with:?? "ssh ‘ [email?protected]‘" and check to make sure that only the key(s) you wanted were added. 
     [ 
    [email?protected] .ssh]# ls? 
     authorized_keys? id_rsa? id_rsa.pub? known_hosts (此时authorized_keys文件,生成代表97主机加密成功;id-rsa为钥匙,id_rsa.pub为锁)? 【3】分发钥匙 使用命令: scp /root/.ssh/id_rsa [email?protected]:/root/.ssh/ 
  [ 
 [email?protected] .ssh]# ls? 
  authorized_keys? id_rsa? id_rsa.pub? known_hosts [ [email?protected] .ssh]#?scp id_rsa [email?protected]:/root/.ssh/ The authenticity of host ‘172.25.254.177 (172.25.254.177)‘ can‘t be established. ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘172.25.254.177‘ (ECDSA) to the list of known hosts. [email?protected]‘s password:? id_rsa??????????????????????????????????????? 100% 1679???? 1.6KB/s?? 00:00? **在177主机下进行验证: 
  [ 
 [email?protected] ~]# ls .ssh/ 
  id_rsa? known_hosts 【4】测试 
  [ 
 [email?protected] ~]# ssh 
 [email?protected] 
  Last login: Wed Jul 25 23:10:43 2018 此时不需要进行root用户的登陆,直接连接成功 ?? 3.sshd的安全设定? ????? 注意:在服务端修改文件的配置:vim /etc/ssh/sshd_config? 此文为装载 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 
