---
title: "配置scp ssh"
author: "flypeace"
date: "2016-08-19T18:04:19Z"
tags: []
categories: ["操作系统"]
slug: "scp-ssh"
draft: false
lastmod: "2016-08-19T18:04:19Z"
id: 2319081
url: "https://host.iteye.com/blog/2319081"
---

1、：生成密匙对

  \[user@rh user]$ ssh-keygen -t rsa  
   Generating public/private rsa key pair.  
   Enter file in which to save the key (/home/user/.ssh/id\_rsa):   --生成的过程中提示输入密钥对保存位置，直接回车，接受默认值  
   Created directory '/home/user/.ssh'.  
    
   Enter passphrase (empty for no passphrase):    --输入一个不同于你的password的密码，直接回车，让它空着，如果输入，后续每次远程连接都会提示输入密码  
   Enter same passphrase again:  
    
   Your identification has been saved in /home/user/.ssh/id\_rsa.  
   Your public key has been saved in /home/user/.ssh/id\_rsa.pub.  
   The key fingerprint is:  
   e0:f0:3b:d3:0a:3d:da:42:01:6a:61:2f:6c:a0:c6:e7user@rh.test.com  
   \[user@rh user]$

其中公共密钥保存在 ~/.ssh/id\_rsa.pub   私有密钥保存在 ~/.ssh/id\_rsa  
修改 .ssh 目录的权限，"chmod 755 ~/.ssh"  
   \[user@rh user]$ chmod 755 ~/.ssh  
   
将id\_rsa.pub公共密钥复制到要访问的机器上，并保存为  
   ~/.ssh/authorized\_keys

大功告成。用ssh scp sftp 访问其他Linux机器时，就不用输入密码了