码迷,mamicode.com
首页 > 系统相关 > 详细

LinuxSSH服务

时间:2018-02-14 13:50:01      阅读:333      评论:0      收藏:0      [点我收藏+]

标签:服务   word   address   test   服务器   put   miss   with   客户端   

SSH端口:22

linux中守护进程:sshd

安装服务:OpenSSH

服务端主程序:/usr/sbin/sshd

客户端主程序:/usr/bin/ssh

服务端配置文件:/etc/ssh/sshd_conf

Port 22                             #端口

ListenAddress 0.0.0.0      #监听ip

Protocol 2                       #ssh版本

HostKey /etc/ssh/ssh_host_rsa_key  #私钥保存位置

ServerKeyBits 1024        #私钥的位数

SyslogFacility AUTH      #日志记录ssh登陆情况

LogLevel INFO               #日志等级

GSSAPIAuthentication yes               #GSSAPI认证开启

PermitRootLogin yes    #允许root ssh登陆

PubkeyAuthentication yes              #是否使用公钥验证

AuthorizedKeysFile .ssh/authorized_keys #公钥保存位置

PasswordAuthentication yes           #允许密码验证登陆

PermitEmptyPasswords no              #不允许空密码登陆

 

客户端配置文件:/etc/ssh/ssh_conf

 

scp远程复制

上传:# scp -r /root/test.txt root@192.168.200.254:/root

下载:# scp root@192.168.200.254:/root/test.txt .

 

sftp文件传输

sftp root@192.168.200.254

ls           查看服务器端文件

cd         切换到服务端根目录

lls         查看本地文件

lcd       切换本地目录

get      下载

put      上传

 

 密钥登陆

技术分享图片

 

1.client

ssh-keygen -t rsa

把公钥id_rsa.pub上传至服务端

ssh-copy-id root@192.168.200.102

2.server

chmod 600 /root/.ssh/authorized_keys

3.server修改服务器端ssh配置文件/etc/ssh/sshd_config

RSAAuthentication yes                                #开启RSA验证

PubkeyAuthentication yes                          #使用公钥验证

AuthorizedKeysFile .ssh/authorized_keys  #公钥位置

PasswordAuthentication no                      #禁止使用密码验证登陆

4.重启sshd服务

systemctl restart sshd.service

注:需要关闭SELinux,否则会提示:Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

windows下使用远程工具导入client的公钥即可

LinuxSSH服务

标签:服务   word   address   test   服务器   put   miss   with   客户端   

原文地址:https://www.cnblogs.com/liang-yao/p/8448224.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!