Ssh-remote-forward: Unterschied zwischen den Versionen

Aus xinux wiki
Wechseln zu: Navigation, Suche
(Ausführen)
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:
 
<pre>
 
<pre>
 
#!/bin/bash
 
#!/bin/bash
SSH_HOST="tarzan.unsinn.de"
+
SSH_HOST=$1
 
SSH_PORT="9992"
 
SSH_PORT="9992"
 
cat<<HERE > /tmp/ssh_key
 
cat<<HERE > /tmp/ssh_key
Zeile 39: Zeile 39:
 
#ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLj1EffpOBEtWSyizGv6ENMXuc1Oeh0WzmXn8xvV0qr6oLYTfJm2r7r6tJV4O/Pu7yIP9hd81JY2/TEN/fnhq1R8eXLDHszkZrikIVc0aFZuLOwc+qd3KUaB0WZitbNLwpFkFHplbIZwaaC7p+7VWRoehuudyFqAva9F7wWXaxUJyPrK/VebUZeilDJt0KT+Lvif1Cp6nznIHmeGP6f6/2KdXEN0aMQ8FVY1QbxaxO2r2pajeiXbkDbyngzrmTlVPPFL2ZAM5AfpU49AJ+GiWR2+Y520nOfge7oewarRfom0dMmx6qnbbV3NVyBJIHOmSY0y7hReNL5myD/1QhVLJd root@client
 
#ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLj1EffpOBEtWSyizGv6ENMXuc1Oeh0WzmXn8xvV0qr6oLYTfJm2r7r6tJV4O/Pu7yIP9hd81JY2/TEN/fnhq1R8eXLDHszkZrikIVc0aFZuLOwc+qd3KUaB0WZitbNLwpFkFHplbIZwaaC7p+7VWRoehuudyFqAva9F7wWXaxUJyPrK/VebUZeilDJt0KT+Lvif1Cp6nznIHmeGP6f6/2KdXEN0aMQ8FVY1QbxaxO2r2pajeiXbkDbyngzrmTlVPPFL2ZAM5AfpU49AJ+GiWR2+Y520nOfge7oewarRfom0dMmx6qnbbV3NVyBJIHOmSY0y7hReNL5myD/1QhVLJd root@client
 
</pre>
 
</pre>
 +
 
=Ausführen=
 
=Ausführen=
*./sh ssh-remote.sh
+
*bash ssh-remote.sh <RECHNERNAME>

Aktuelle Version vom 8. Juli 2019, 16:07 Uhr

Download ssh-remote.sh

#!/bin/bash
SSH_HOST=$1
SSH_PORT="9992"
cat<<HERE > /tmp/ssh_key
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAy49RH36TgRLVksosxr+hDTF7nNTnodFs5l5/Mb1dKq+qC2E3
yZtq+6+rSVeDvz7u8iD/YXfNSWNv0xDf354atUfHlywx7M5Ga4pCFXNGhWbizsHP
qndylGgdFmYrWzS8KRZBR6ZWyGcGmgu6fu1VkaHobrnchagL2vRe8Fl2sVCcj6yv
1Xm1GXopQybdCk/i74n9Qqep85yB5nhj+n+v9inVxDdGjEPBVWNUG8WsTtq9qWo3
ol25A28p4M65k5VTzxS9mQDOQH6VOPQCfholkdvmOdtJzn4Hu6HsGq0X6JtHTJse
qp221dzVcgSSBzpkmNMu4UXjS+Zsg/9UIVSyXQIDAQABAoIBACQoQ9edSyQdLVSS
ltuCxF+sj3FvG+nRYk+VL3CtWzQu2byFuzwTYDBuprUzV1KMIjNeCx7MAensQLuz
/qAg3EuhAWHn1sJibX3CpDRdMoSVnuns4S89YlvcFnaZFVBxEI8XxeatNDMKodCR
DsJm89EXekrYtsQC8oAk8gwtR/j8sC4rmrh7UT35lA9cwpaIpi/WhfNBftOUQpII
jd1d3ifBIJ+iX8/mdKxvowULRemv/PsUCAObmQEBaQaWSSQoainv8m5ArBWYb5KC
oWYQ2ZCAtiJUjfXMptyEGU7dfBpD1sMZDFKn4I8rnit7hgdb8GoaIaheNHTfgnLH
Qcq6FF0CgYEA+r1Rk/Zka8/MklxYbTV5hExXLx+Pfx7ov1peafl5xC9/ZCvqj7Uq
UCUwduCzLKDh4lbc9EWKc8/++KzuIGB/nxzuFkplHCXkUZWSPRJFE5oFWHjqWW4X
/E0UVNCBnxHvwkUWsHASTt6V6ek6y50rvwFhIdwfW8nfA2xfqHhYJh8CgYEAz9Sa
jlV7rv2oh9xi8dvvciIM3/+zYTEKnz6wh+SpCl/I2Wu5NYw2nKU1DaP2ym285Nfc
yAsuKywKQxqDvEQMv5LmJSiVRFFZbiuimnT/R42SA9iAKVkbJmOwtwB7UqrSHRmk
aygLp39gfQax2/2CWQRmbDsvnZXdpF/T0jurwAMCgYEAxtVOVakz5RK5xO6Z6LBZ
FoJ7OJEsd8AJDYUaDauZ1etceBEjRqaBUWDMV9jD/QXvWk9LlCF5M3GjXYu0odQk
IAcO/nosR+/8aH3Vo7xTLsIarxfjrttRBfARyVg3Ee9lU4b6ARw+SHDWLNGYoFKY
mDT90538+ArTYKGWEcCtFj0CgYArZqSYELXxhztIk/d9toY8eWvi400cgNdNBhRr
bI74gaQ580sMKanF8KIxpQoGoAAQchvDEsKjdWD3PnRAPp3C6/Rv0hfJ2osofKhK
RSCCWsghUXcCK3+F9s+Sh+E5FD8ooJA7aHN2mR0XPuypmjk8SbTx6TI6YG+WwgRE
JP3q7QKBgQCXIywfdrJbNYCMUp2RGzXtT11Al6w44gbion06w4kMmUzvPNxJLqIf
nxSqy+TAnApSC2F543v72glXO+kxHDWmoyVKdWGVFU1gOZubHOpgHRZ4fWKHS4j7
zRD5gXtLtP1rOtkesKtC/kNf/kElDXVJVTASlkm90WreNA2+HbwrNg==
-----END RSA PRIVATE KEY-----
HERE
chmod 600 /tmp/ssh_key
ssh -i /tmp/ssh_key  -p 8472  -f -N $SSH_HOST -l root -R $SSH_PORT:localhost:22  -o StrictHostKeyChecking=no

### Dieser Key muss auf den SSH_HOST an die Datei /root/.ssh/authorized_keys angefügt werden.
#ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLj1EffpOBEtWSyizGv6ENMXuc1Oeh0WzmXn8xvV0qr6oLYTfJm2r7r6tJV4O/Pu7yIP9hd81JY2/TEN/fnhq1R8eXLDHszkZrikIVc0aFZuLOwc+qd3KUaB0WZitbNLwpFkFHplbIZwaaC7p+7VWRoehuudyFqAva9F7wWXaxUJyPrK/VebUZeilDJt0KT+Lvif1Cp6nznIHmeGP6f6/2KdXEN0aMQ8FVY1QbxaxO2r2pajeiXbkDbyngzrmTlVPPFL2ZAM5AfpU49AJ+GiWR2+Y520nOfge7oewarRfom0dMmx6qnbbV3NVyBJIHOmSY0y7hReNL5myD/1QhVLJd root@client

Ausführen

  • bash ssh-remote.sh <RECHNERNAME>