Linux遠程連接工具之ssh命令
如需轉載請標明出處:http://blog.csdn.net/itas109
QQ技術交流羣:129518033
文章目錄
環境:
linux: deepIn 15.11
windows: win7
前言
Secure Shell(SSH)是一種加密網絡協議,用於在不安全的網絡上安全地運行網絡服務。 典型的應用程序包括遠程命令行登錄和遠程命令執行,但是任何網絡服務都可以使用SSH進行保護。
本文介紹如何使用ssh命令進行遠程連接。
1.ssh服務端安裝
# debian/deepin/ubuntu
sudo apt-get install openssh-server
# redhat/centos
sudo yum install openssh-server
# 啓動ssh服務
sudo systemctl start sshd
# 設置ssh開機自啓動
sudo systemctl enable sshd
ssh服務配置
vi /etc/ssh/ssh_config
2.ssh命令安裝
2.1 linux
# debian/deepin/ubuntu
sudo apt-get install openssh-client
# redhat/centos
sudo yum install openssh-clients
2.2 windows
ssh在windows下的命令主要包括ssh.exe、scp.exe、sftp.exe
- MobaXterm(★)
Windows增強版終端,支持SSH客戶端、widnows終端(支持基本linux命令)、VNC、FTP、串口等協議等
version: MobaXterm Home Edition v20.2
https://mobaxterm.mobatek.net/
- openssh
OpenSSH for Windows
version:setupssh-8.3p1-1.exe
https://www.mls-software.com
3.ssh命令的使用
3.1 ssh遠程連接
用法
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
[-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
[-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
[-i identity_file] [-J [user@]host[:port]] [-L address]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] destination [command]
連接到192.168.129.164的用戶dev
ssh [email protected] -p 22
ssh [email protected] -p 22
[email protected]'s password:
Welcome to Deepin 15.11 GNU/Linux
* Homepage:https://www.deepin.org/
* Bugreport:https://feedback.deepin.org/feedback/
* Community:https://bbs.deepin.org/
Last login: Thu Jun 25 18:10:26 2020 from 192.168.129.1
dev@dev-PC:~$ ls
b b.txt Desktop Documents Downloads Music Pictures Videos 模板
3.2 ssh上傳文件(夾)
- scp命令(不需要連接ssh)
用法
usage: scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file]
[-J destination] [-l limit] [-o ssh_option] [-P port]
[-S program] source ... target
ssh上傳文件a.txt到~目錄
ssh上傳文件a文件夾到~目錄
scp a.txt [email protected]:~
scp -r a [email protected]:~
scp a.txt [email protected]:~
[email protected]'s password:
a.txt 100% 0 0.0KB/s 00:00
scp -r a [email protected]:~
[email protected]'s password:
ssh [email protected] -p 22
dev@dev-PC:~$ ls -l
總用量 32
drwxrwx--- 2 dev dev 4096 6月 25 18:13 a
-rwxr-x--- 1 dev dev 0 6月 25 18:11 a.txt
-rw-r--r-- 1 dev dev 0 6月 25 18:17 b
-rw-r--r-- 1 dev dev 0 6月 25 18:18 b.txt
...
- lzsz命令(需要連接ssh,需要SSH客戶端支持)
安裝
# debian/deepin/ubuntu
sudo apt-get install lrzsz
# redhat/centos
sudo yum install lrzsz
- sftp命令(不需要未連接ssh)
sftp [email protected]
[email protected]'s password:
Connected to 192.168.129.164.
sftp> put C:/a.txt .
Uploading C:/a.txt to /home/dev/./a.txt
C:/a.txt 100% 0 0.0KB/s 00:00
sftp> ls
Desktop Documents Downloads Music Pictures Videos a.txt b
b.txt 模板
3.3 ssh下載文件(夾)
- scp命令(不需要連接ssh)
用法
usage: scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file]
[-J destination] [-l limit] [-o ssh_option] [-P port]
[-S program] source ... target
ssh上傳文件b.txt到當前目錄
ssh上傳文件b文件夾到當前目錄
scp [email protected]:~/b.txt .
scp -r [email protected]:~/b .
scp [email protected]:~/b.txt .
[email protected]'s password:
b.txt 100% 0 0.0KB/s 00:00
scp -r [email protected]:~/b .
[email protected]'s password:
ls -l
total 2
drwxr-xr-x 1 win7 UsersGrp 0 Jun 25 18:07 a
-rw-r--r-- 1 win7 UsersGrp 0 Jun 25 18:07 a.txt
drwxr-xr-x 1 win7 UsersGrp 0 Jun 25 18:19 b
-rw-r--r-- 1 win7 UsersGrp 0 Jun 25 18:19 b.txt
...
- lzsz命令(需要連接ssh,需要SSH客戶端支持)
安裝
# debian/deepin/ubuntu
sudo apt-get install lrzsz
# redhat/centos
sudo yum install lrzsz
- sftp命令(不需要連接ssh)
sftp [email protected]
[email protected]'s password:
Connected to 192.168.129.164.
sftp> get b.txt C:/
Fetching /home/dev/b.txt to C:/b.txt
License
License under CC BY-NC-ND 4.0: 署名-非商業使用-禁止演繹
如需轉載請標明出處:http://blog.csdn.net/itas109
QQ技術交流羣:129518033
Reference:
NULL