Linux下SCP使用技巧
2014-03-13 11:30
375 查看
The following commands are based on RPC (Remote Procedure calls).
They allow to copy files, execute a command or
open a terminal session on the remote host.
rsh (remote shell):
Utility for executing a command on a remote machine.
For security reasons,
ssh is the preferable service for logging in remotely.
ssh (secure shell):
rcp (remote copy), scp (secure copy):
These two commands copy files from one machine
to another using a similar notation to cp.
scp is the secure version from the ssh package.
They allow to copy files, execute a command or
open a terminal session on the remote host.
rsh (remote shell):
Utility for executing a command on a remote machine.
rsh [-l username] remote_machine [command]
For security reasons,
ssh is the preferable service for logging in remotely.
ssh (secure shell):
ssh [-l ] remote_machine
rcp (remote copy), scp (secure copy):
These two commands copy files from one machine
to another using a similar notation to cp.
scp is the secure version from the ssh package.
rcp [-r] [uesr@host1:]file1 [user@host2:]file2 scp [-r] [[user@]host1:]file1 [...] [[user@]host2:]file2 Options: Copy recursively: -r 一:简介 虽然目前大家都认为telnet/ftp/rsh作为不安全的服务已经不太使用,但在局域网内部 的某些情况下仍然广泛地被使用,特别是安全性不是很重要的场合下,某些服务如FTP, 由于历史较长,至今大多数场合仍然大有用处。很多人在使用这些服务直接登录作为root 时遇到问题,本文就简单地介绍一下设置方法和相关问题。 二:环境 假设本文的所有操作环境是Redhat Linux,一台为telnet/ftp/rsh/ssh客户,IP为 192.168.0.2,主机名为 client.domain.com;另一台为服务器,IP为192.168.0.1,主机名为 server.domain.com,两者都运行redhat linux 7.1 . 三:用法 1. 直接telnet作为root. a. 在服务器server.domain.com上运行/usr/sbin/ntsysv后选中telnet服务,击OK。 b. 运行#/sbin/service xinetd restart 启动telnet服务 c. 运行#echo "pts/0" >> /etc/securetty 和 #echo "pts/1" >> /etc/securetty ...... 更多的远程终端允许直接登录作为root d. 确保在server.domain.com上的/etc/hosts中有类似下面的行。 192.168.1.2 client.domain.com client 如果没有,则在server上运行echo "192.168.1.2 client.domain.com client" >> /etc/hosts 至此你应该能从client远程telnet直接作为root了。 如果服务器是redhat 6.x,则加单个数字如0,1,2,3...到/etc/securetty后面,一个数 字一行,必须以0开始。 仅仅加数字而己,没有pts,tty。 如果服务器是redhat 5.x,则加ttyp0, ttyp1,ttyp2... 等到/etc/securetty. 经常有人问,为什么telnet/ftp进服务器时需要等很久?那是因为当服务器检测出有客户 远程连接进来时,它知道客户的IP,但根据telnet/ftp服务的内部机制,它需要反向检 查该IP的域名,如果你有DNS服务器且设置了反向域名,则很快查到,若没有,则简单地 在服务器的/etc/hosts中加入客户的记录就可以了。 2. 直接rsh作为root. a. 在服务器上运行/urs/bin/ntsysv选中rexec ,rlogin ,rsh三项服务。 b. 运行#/sbin/service xinetd restart 启动该三项服务。 c. 运行#echo "rexec" >> /etc/securetty;echo "rlogin" >> /etc/securetty;echo "rsh" >> /etc/securetty d. 在服务器上运行#echo "192.168.0.2 root" >> /root/.rhosts 或者 #echo "client root" >> /root/.rhosts且确保在服务器上的/etc/hosts中有 client的记录 192.168.0.2 client.domain.com client 至此你应该可以从client直接以root身份rsh到服务器不需密码了。 注: 仅仅redhat 7.x 开始需要为rsh设置/etc/securetty. 3. 直接ftp作为root. 这个比较简单,就是在server上的/etc/ftpusers中的root一行前面放个注释#即可。 在现代的网络技术下,telnet/rsh/ftp都可以被ssh/scp代替了,甚至已经有了一个 winscp,图形化的SCP工具,在http://winscp.vse.cz/eng/ , 免费的windows ssh客 户有许多,象tera term , putty等等。 不过,FTP在某些场合仍然有它的用处。下面例举两种: a. FTP可以直接把远端服务器上某个目录压缩后传送到客户端,如远程服务器有sbin目 录,可以用get sbin.tar.gz直接把整个目录压缩后FTP下来成为单个压缩文件。这个方 式可以很好地用在远程复制整个 linux OS。 b. 为了远程复制另一台linux OS,可以用redhat 光盘启动到准备进行分区的界面(选择 自动还是手动分区的界面),然后用ALT+F2切换到第二个终端,设置网卡的IP和默认网关, 用fdisk/e2fsck 分区用格式化本地硬盘,用FTP远程得到服务器的所有目录除了proc目 录,然后即可以复制一台与远端一样的服务器。 详细做法请参考《文章荟萃》中另一篇文章 http://www.linuxforum.net/doc/cp-wu.html 《如何远程复制另一台Linux服务器及 相关问题 》。 4. 直接ssh作为root. OpenSSH的默认设置sshd_config是允许登录作为root的 PermitRootLogin yes ,你可 以改为no去禁止这个功能增强安全性。 为了直接不用密码登录作为root,最好是采用RSA键对认证方式进行。
相关文章推荐
- linux中scp命令使用技巧详解(传输速度)
- 1-3-linux下vim使用快捷键操作以及解决工作中问题的技巧
- Linux 开发高级使用技巧之--内存泄漏工具
- 技巧:Linux 动态库与静态库制作及使用详解
- Linux终端使用技巧
- linux 技巧:使用 screen 管理你的远程会话
- 最有用的Linux命令行使用技巧集锦
- linux 技巧:使用 screen 管理你的远程会话
- Linux经典实用的使用技巧33则
- 如何在使用 scp 命令时递归地排除文件 | Linux 中国
- Linux使用技巧9--用dpkg管理你的软件
- Linux中cp和scp命令的使用方法
- Linux scp 使用详解
- Linux scp基本使用方法
- Linux 命令行工具使用小贴士及技巧
- linux使用技巧及常见问题
- 使用scp命令在两台linux上对拷文件或者文件夹
- linux 技巧:使用 screen 管理你的远程会话
- Linux文件远程拷贝命令scp的使用
- 最实用的 Linux 命令行使用技巧汇总