1.SSH

1)直接登录(每次都需要对方密码)

[root@rhel61 桌面]# ssh root@192.168.1.110

The authenticity of host '192.168.1.110 (192.168.1.110)' can't be established.
RSA key fingerprint is c9:8f:e7:f3:ce:e4:0c:9a:cf:31:ca:87:7f:f1:65:dd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.110' (RSA) to the list of known hosts.
root@192.168.1.110's password: 
Last login: Sun Feb 10 16:55:39 2013 from 192.168.1.106
[root@centos632 ~]# exit
logout
Connection to 192.168.1.110 closed.
 
2)利用RSA密钥对(只需输入一次密码就行,以后不用输)
 
[root@centos632 ~]# ssh-keygen           (ssh-keygen -t rsa/dsa)默认RSA
 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
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:
f7:49:aa:b0:b5:a0:3a:83:a3:6b:8c:f6:90:60:e2:3e root@centos632.xueyue8.com
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|                 |
|o.      S . .    |
|= .      . + .   |
|o=    o . . o    |
|=E+  . = o       |
|*++=. . o        |
+-----------------+
[root@centos632 ~]# scp /root/.ssh/id_rsa.pub 192.168.1.102:/root/.ssh/authorized_keys
 
The authenticity of host '192.168.1.102 (192.168.1.102)' can't be established.
RSA key fingerprint is 54:ae:d0:78:06:9b:82:c2:2c:5a:26:a3:c0:73:ce:a7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.102' (RSA) to the list of known hosts.
root@192.168.1.102's password: 
id_rsa.pub                                    100%  408     0.4KB/s   00:00    
[root@centos632 ~]# ssh 192.168.1.102
[root@rhel63 ~]# ll                         (不需要输入密码了)
总用量 100
-rw-------. 1 root root  1633 2月  10 13:14 anaconda-ks.cfg
-rw-r--r--. 1 root root 47254 2月  10 13:14 install.log
-rw-r--r--. 1 root root 11185 2月  10 13:12 install.log.syslog
drwxr-xr-x. 2 root root  4096 2月  10 13:18 公共的
drwxr-xr-x. 2 root root  4096 2月  10 13:18 模板
drwxr-xr-x. 2 root root  4096 2月  10 13:18 视频
drwxr-xr-x. 2 root root  4096 2月  10 13:18 图片
drwxr-xr-x. 2 root root  4096 2月  10 13:18 文档
drwxr-xr-x. 2 root root  4096 2月  10 13:18 下载
drwxr-xr-x. 2 root root  4096 2月  10 13:18 音乐
drwxr-xr-x. 2 root root  4096 2月  10 16:48 桌面
[root@rhel63 ~]# exit
logout
Connection to 192.168.1.102 closed.
[root@centos632 ~]# ssh 192.168.1.102        (不需要输入密码了)
Last login: Sun Feb 10 23:39:48 2013 from 192.168.1.110
 
3)SCP的使用
 
下载远程数据到本地目录
scp user@remote.servername:/remote_path/filename /local_path/         //下载文件
scp -r user@remote.servername:/remote_path /local_path                //下载目录
 
上传本地数据到远程数目录
scp  /local_path/filename user@remote.servername:/remote_path/         //上传文件
scp -r  /local_path user@remote.servername:/remote_path                //上传目录
 
 
scp -r root@192.168.1.102:/var/ftp . ( . 代表当前目录) //下载/var/ftp 下文件到当前目录
scp -r root@192.168.1.102:/var/ftp /var/ttp/
scp  /var/ttp/xxf.txt root@192.168.1.102:/var/ftp/