zoukankan      html  css  js  c++  java
  • Linux中的scp命令的使用方法和免登入方法

    一、scp 命令:

    scp 是 secure copy 的缩写,scp 是Linux系统下基于 ssh 登入进行安全的远程文件拷贝命令。

    格式为:scp [可选参数]  file_source  file_target

    1、从本地复制到远程

    格式为: scp local_file remote_username@remote_ip : remote_folder

    实例为: scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music

    2、从远程复制到本地

    从远程复制到本地,只要将从本地复制到远程的命令的后2个参数调换顺序即可,如下:

    scp root@www.runoob.com:/home/root/others/music /home/space/music/1.mp3

    如果远程服务器防火墙有为scp命令设置了指定的端口,我们需要使用 -P 参数来设置命令的端口号,如下:

    scp -P 4588 remote@www.runoob.com:/usr/local/sin.sh /home/administrator

    使用scp命令要确保使用的用户具有可读取远程服务器响应文件的权限,否则scp命令是无法起作用的

    详细请查看菜鸟教程:https://www.runoob.com/linux/linux-comm-scp.html

    二、使用scp命令免登入方法如下:

    [root@WebServer3 ~]# ssh-keygen -t 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:
    a2:1d:43:32:26:06:68:48:d5:62:16:6d:a2:c7:53:8c root@WebServer3

    输入 ssh-keygen -t rsa命令后直接都按回车就行。

    第一提示是密钥保存位置

    Enter file in which to save the key (/root/.ssh/id_rsa):

    直接回车保存到默认地方 /root/.ssh/id_rsa

    第二个提示是输入一个不同于你的password的密码。直接按回车,不输入密码,保持密码为空。

    其中公共密钥保存在 ~/.ssh/id_rsa.pub 
    私有密钥保存在 ~/.ssh/id_rsa 
    拷贝密钥文件到目标服务器

    [root@WebServer3 ~]#scp ~/.ssh/id_rsa.pub 192.168.0.23:/root/.ssh/authorized_keys

    配置完毕,你在这台机器上用scp ssh sftp 命令访问目标机器的时候就不用输入密码了

    参考文档:https://www.cnblogs.com/jikexianfeng/p/5813718.html

  • 相关阅读:
    C#使用WINDOW
    赵四小姐从十六岁开始跟张学良。跟一年,属奸情;跟三年,算偷情;跟六十年,便成为千古爱情!
    Microsoft Visual Studio 2010(VS2010)正式版 CDKEY / SN:
    C#中byte[]与string的转换
    sqlserver waitfor time '10:00' waitfor delay '1:00' 时间延时 和 间隔
    免费下载 精英讲解
    在决定使用ClickOnce发布你的软件前,应该知道的一些事情
    Windows7下注册OCX的注意事项
    用命令行以最快速简单的方式搭建MySQL数据库
    设计模式探索系列之Bridge模式
  • 原文地址:https://www.cnblogs.com/yanmou/p/11458893.html
Copyright © 2011-2022 走看看