1. 程式人生 > >LinuxSSH服務

LinuxSSH服務

遠程工具 下使用 png 服務端 關閉selinux log bubuko 主程 open

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 [email protected]:/root

下載:# scp [email protected]:/root/test.txt .

sftp文件傳輸

sftp [email protected]

ls 查看服務器端文件

cd 切換到服務端根目錄

lls 查看本地文件

lcd 切換本地目錄

get 下載

put 上傳

密鑰登陸

技術分享圖片

1.client

ssh-keygen -t rsa

把公鑰id_rsa.pub上傳至服務端

ssh-copy-id [email protected]

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服務