1er commit
De la docs au format Mkdocs
This commit is contained in:
101
docs/Linux/ssh.md
Normal file
101
docs/Linux/ssh.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# Commande ssh
|
||||
|
||||
#### Se connecter à un serveur par un autre port que 22:
|
||||
|
||||
```bash
|
||||
bruno@macbook-pro:~$ ssh bruno@192.168.1.7 -p 42666
|
||||
bruno@192.168.1.7's password:
|
||||
bruno@DS916:/var/services/homes/bruno $
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Fixer le message WARNING: UNPROTECTED PRIVATE KEY FILE!
|
||||
|
||||
On réinitilalise les permissions des clés:
|
||||
|
||||
```bash
|
||||
bruno@macbook-pro:~$ sudo chmod 600 ~/.ssh/id_rsa
|
||||
bruno@macbook-pro:~$ sudo chmod 600 ~/.ssh/id_rsa
|
||||
```
|
||||
|
||||
Si cela ne suffit pas:
|
||||
|
||||
```bash
|
||||
bruno@macbook-pro:~$ sudo chmod 600 ~/.ssh/known_hosts
|
||||
bruno@macbook-pro:~$ sudo chmod 755 ~/.ssh
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Copier un fichier:
|
||||
|
||||
```bash
|
||||
macbook-pro:~ bruno$ ssh root@192.168.1.8 "cat prefs.tar.gz"> prefs.tar.gz
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Exécuter une (ou plusieurs) commande sur un serveur distant:
|
||||
|
||||
```bash
|
||||
macbook-pro:~ bruno$ ssh root@192.168.1.8 hostname
|
||||
DiskStation
|
||||
|
||||
bruno@SilverBook:~$ ssh -p34987 bruno@xxxxxxx.synology.me 'hostname ; uptime'
|
||||
bruno@xxxxxxx.synology.me's password:
|
||||
DS916
|
||||
07:56:40 up 2 days, 19:50, 0 users, load average: 1.13, 1.15, 1.14
|
||||
|
||||
bruno@SilverBook:~$ ssh -p34987 bruno@xxxxxxx.synology.me << EOF
|
||||
> uname -a
|
||||
> lscpu | grep "^CPU(s)"
|
||||
> grep -i memtotal /proc/meminfo
|
||||
> EOF
|
||||
Pseudo-terminal will not be allocated because stdin is not a terminal.
|
||||
bruno@clicclac.synology.me's password:
|
||||
Linux DS916 3.10.102 #15266 SMP Mon Mar 26 15:12:32 CST 2018 x86_64 GNU/Linux synology_braswell_916+
|
||||
/bin/bash: line 2: lscpu: command not found
|
||||
MemTotal: 1963472 kB
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Exécuter un script distant sur un serveur distant:
|
||||
|
||||
```bash
|
||||
bruno@SilverBook:~$ ssh -p34987 bruno@xxxxxxx.synology.me ./test.sh
|
||||
bruno@clicclac.synology.me's password:
|
||||
09:55:03 up 2 days, 21:49, 0 users, load average: 1.14, 1.25, 1.23
|
||||
DS916
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Exécuter un script local sur un serveur distant:
|
||||
|
||||
```bash
|
||||
bruno@SilverBook:~$ ssh -p34987 bruno@xxxxxxx.synology.me 'bash -s' < test.sh
|
||||
bruno@xxxxxxx.synology.me's password:
|
||||
toto
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Mode verbose
|
||||
|
||||
```bash
|
||||
bruno@macbook-pro:~$ ssh -vvv dsm916
|
||||
OpenSSH_6.9p1, LibreSSL 2.1.8
|
||||
debug1: Reading configuration data /Users/bruno/.ssh/config
|
||||
debug1: /Users/bruno/.ssh/config line 3: Applying options for dsm916
|
||||
debug1: Reading configuration data /etc/ssh/ssh_config
|
||||
debug1: /etc/ssh/ssh_config line 20: Applying options for *
|
||||
debug1: /etc/ssh/ssh_config line 102: Applying options for *
|
||||
debug2: ssh_connect: needpriv 0
|
||||
debug1: Connecting to 192.168.1.7 [192.168.1.7] port 22.
|
||||
debug1: Connection established.
|
||||
debug1: identity file /Users/bruno/.ssh/id_dsa type 2
|
||||
.../...
|
||||
bruno@DS916:/var/services/homes/bruno $
|
||||
```
|
||||
Reference in New Issue
Block a user