Difference between revisions of "Ssh (OpenSSH client)"

From wikieduonline
Jump to navigation Jump to search
 
(42 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
{{lowercase}}
 
<code>ssh</code><ref>http://man7.org/linux/man-pages/man1/ssh.1.html</ref> is the [[OpenSSH]] [[ssh clients|ssh client]] for logging or executing commands into remote devices/machines
 
<code>ssh</code><ref>http://man7.org/linux/man-pages/man1/ssh.1.html</ref> is the [[OpenSSH]] [[ssh clients|ssh client]] for logging or executing commands into remote devices/machines
 +
* Man page: https://linux.die.net/man/1/ssh
 +
* <code>[[ssh --help]]</code>
  
 
       ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
 
       ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
Line 6: Line 9:
 
         [-W host:port] [-w local_tun[:remote_tun]] destination [command]
 
         [-W host:port] [-w local_tun[:remote_tun]] destination [command]
  
-X Enables X11 forwarding
+
* <code>-X Enables X11 [[forwarding]]</code>
 
+
* <code>-N Do not execute a [[remote command]]. This is usefull for just [[forwarding]] ports</code>
[[OpenSSH changelog|ssh -V]]
+
* <code>[[ssh -vvv]]</code>
 
+
* <code>[[ssh -V]]</code>
 +
* <code>[[ssh -t]]</code>
 +
* <code>[[ssh -O]]</code>
 +
* <code>ssh -o ConnectTimeout=100</code>
 +
* <code>[[ssh -i]]</code>
 +
* <code>[[ssh -L]]</code>
 +
* <code>[[ssh -R]]</code>
  
 
Windows: Settings > Apps and click “Manage optional features” under Apps & features.
 
Windows: Settings > Apps and click “Manage optional features” under Apps & features.
  
 
== Configuration ==
 
== Configuration ==
* Configuration file: <code>~/.ssh/[[config]]</code>
+
* Configuration file: <code>[[~/.ssh/config]]</code>
 
+
* <code>[[~/.ssh/environment]]</code>
  
 
== Usage ==
 
== Usage ==
* <code>[[ssh]] REMOTE_USERNAME@REMOTE_SERVER_NAME_OR_IP</code>
+
* <code>[[ssh]] remote_User@server_Name_Or_IP</code>
* <code>[[ssh]] -vvv REMOTE_USERNAME@REMOTE_SERVER_NAME_OR_IP</code> (<code>-v</code> increase verbosity, maximum 3)
+
* <code>ssh  [email protected] -p 1111 [[-i]] ./yourprivkey</code>
 +
* <code>[[ssh -vvv]] REMOTE_USERNAME@REMOTE_SERVER_NAME_OR_IP</code> (<code>-v</code> increase verbosity, maximum 3)
 
** <code>[[ssh]] -vvv REMOTE_USERNAME@REMOTE_SERVER_NAME_OR_IP 2>&1 | grep "STRING_TO_SEARCH" </code>  
 
** <code>[[ssh]] -vvv REMOTE_USERNAME@REMOTE_SERVER_NAME_OR_IP 2>&1 | grep "STRING_TO_SEARCH" </code>  
 
Execute a remote command:
 
Execute a remote command:
 
* <code>ssh USERNAME@SERVER_NAME  '/path/to/remote/scripts/backup.[[sh]]'</code>
 
* <code>ssh USERNAME@SERVER_NAME  '/path/to/remote/scripts/backup.[[sh]]'</code>
  
* <code>ssh -Q kex SERVER</code>
+
* <code>[[ssh -Q]] kex SERVER</code>
 +
 
 +
== Example commands ==
 +
* <code>ssh -o [[StrictHostKeyChecking]]=accept-new [email protected]</code> (since [[OpenSSH 7.5]], March 2017)
 +
* <code>ssh -o StrictHostKeyChecking=no [email protected]</code><ref>https://serverfault.com/a/132973</ref>
 +
* <code>ssh -Q [[kex]] SERVER</code>
 +
* <code>ssh -o [[MACs]]=[[hmac-sha2-256]] HOSTNAME</code>
  
 
== [[Multiplexing]] options ==
 
== [[Multiplexing]] options ==
<pre>ssh -O check server.example.org or ssh -O check [email protected]  
+
[[ssh -O]] check server.example.org or ssh -O check [email protected]  
Master running (pid=26289)
+
Master running (pid=26289)
</pre>
 
  
<pre>
+
ssh -O check [email protected]  
ssh -O check [email protected]  
+
Control socket connect(/path/): No such file or directory
Control socket connect(/path/): No such file or directory
 
</pre>
 
  
 
To stop an specific multiplexed session:
 
To stop an specific multiplexed session:
Line 46: Line 59:
  
 
== Logs ==
 
== Logs ==
  ssh -i id_ed25519_xxxxx.pub SERVER_NAME
+
  [[ssh -i]] id_ed25519_xxxxx.pub SERVER_NAME
 
  Load key "id_ed25519_xxxxx.pub": invalid format
 
  Load key "id_ed25519_xxxxx.pub": invalid format
 
  Solution:
 
  Solution:
Line 52: Line 65:
 
  ssh -i id_ed25519_xxxxx SERVER_NAME
 
  ssh -i id_ed25519_xxxxx SERVER_NAME
  
* [[Unable to negotiate with]] ([[KexAlgorithms]])
+
* <code>[[Unable to negotiate with]] ([[KexAlgorithms]])</code>
  
 
== Activities ==
 
== Activities ==
Line 58: Line 71:
 
* [[Configure OpenSSH to reuse ssh connections]]
 
* [[Configure OpenSSH to reuse ssh connections]]
 
* [[Execute a command in parallel by ssh]]
 
* [[Execute a command in parallel by ssh]]
 +
* <code>[[ssh]] -o [[PreferredAuthentications]]=keyboard-interactive -o [[PubkeyAuthentication]]=no host1.example.org</code>
 +
* [[Reverse SSH tunneling]]
 +
 +
== Configuration ==
 +
* <code>[[CheckHostIP]]</code>
 +
 +
== Related ==
 +
* <code>[[gcloud compute ssh]]</code>
 +
* [[Load key ... invalid format]]
  
 
== See also ==
 
== See also ==
* {{OpenSSH}}
+
* {{ssh (openSSH)}}
* {{ncat}}
 
* {{tmux}}
 
 
* {{ssh clients}}
 
* {{ssh clients}}
  
 
[[Category:Networking]]
 
[[Category:Networking]]
 
[[Category:Linux]]
 
[[Category:Linux]]

Latest revision as of 13:54, 14 July 2023

ssh[1] is the OpenSSH ssh client for logging or executing commands into remote devices/machines

     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 destination] [-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]

Windows: Settings > Apps and click “Manage optional features” under Apps & features.

Configuration[edit]

Usage[edit]

  • ssh remote_User@server_Name_Or_IP
  • ssh [email protected] -p 1111 -i ./yourprivkey
  • ssh -vvv REMOTE_USERNAME@REMOTE_SERVER_NAME_OR_IP (-v increase verbosity, maximum 3)
    • ssh -vvv REMOTE_USERNAME@REMOTE_SERVER_NAME_OR_IP 2>&1 | grep "STRING_TO_SEARCH"

Execute a remote command:

  • ssh USERNAME@SERVER_NAME '/path/to/remote/scripts/backup.sh'

Example commands[edit]

Multiplexing options[edit]

ssh -O check server.example.org or ssh -O check [email protected] 
Master running (pid=26289)
ssh -O check [email protected] 
Control socket connect(/path/): No such file or directory

To stop an specific multiplexed session:

ssh -O stop [email protected]

Avoid using Multiplexing for a connections:

ssh -o "ControlMaster=no" server.example.org


See also: Configure OpenSSH to reuse ssh connections

Logs[edit]

ssh -i id_ed25519_xxxxx.pub SERVER_NAME
Load key "id_ed25519_xxxxx.pub": invalid format
Solution:
Use private key instead of public key [3]
ssh -i id_ed25519_xxxxx SERVER_NAME

Activities[edit]

Configuration[edit]

Related[edit]

See also[edit]

  • http://man7.org/linux/man-pages/man1/ssh.1.html
  • https://serverfault.com/a/132973
  • https://stackoverflow.com/a/48330113
  • Advertising: