SSH: Difference between revisions

From miki
Jump to navigation Jump to search
(→‎SSH-Tunnel: Patch to prevent double argument expansion...)
(ssh_config)
Line 44: Line 44:
==== Troubleshooting ====
==== Troubleshooting ====
* <tt>~/bin/ssh.pl</tt> from <font color="red">''ssh-tunnel''</font> package currently interferes with the command. This is due to double argument processing and expansion. See patch above on v2.26.
* <tt>~/bin/ssh.pl</tt> from <font color="red">''ssh-tunnel''</font> package currently interferes with the command. This is due to double argument processing and expansion. See patch above on v2.26.

== SSH Config ==
SSH can be configured through file <tt>~/.ssh/config</tt>. See <tt>[http://linux.die.net/man/5/ssh_config man ssh_config]</tt> for more information. The format is as follows:

<source lang=bash>
# Specific configuration options for host host1
Host host1
Option1 parameter
Option2 parameter

# General configuration options for all hosts.
# Options in this section applies if same option was *not already specified* in a relevant host section above.
Host *
Option1 parameter
Option2 parameter
</source>

The value to use for each option is given by the first section that matches the host specification and that provides a value for that option. So section <tt>Host *</tt> should always be at the end of the file, since any subsequent section will be ignored.

=== ProxyCommand ===
Specify the proxy command used by ssh to deal with proxies. If a default command is specified in <tt>host *</tt>, it can be overridden in a specific host section (use '''ProxyCommand none''' to tell ssh that there is no proxies).

<source lang=bash>
Host myhost
ProxyCommand none
Host *
ProxyCommand /usr/local/bin/ssh-tunnel.pl -f - - %h %p
</source>

Revision as of 10:42, 21 January 2009

SSH GUI

Gnome/Nautilus

  • Under Gnome, one can uses menu PlacesConnect to Server... to connect to a remote server in Nautilus. The connection can be bookmarked for future use.
  • The syntax for address bar in Nautilus is sftp://username@server/folder.

KDE/Konqueror

  • Use KIO fish or sftp to establish a SSH or SFTP connection in Konqueror.

gftp

  • gftp is a free multithreaded file transfer client for *NIX based machines. It supports the FTP, FTPS (control connection only), HTTP, HTTPS, SSH and FSP protocols.

SSH Console

SSH-Tunnel

  • See official page on Yobi.
  • Here a patch on ssh-tunnel-v2.26 to prevent double expansion in command arguments.
--- ssh-tunnel-2.26/ssh.pl      2007-04-15 20:15:36.000000000 +0200
+++ ssh-tunnel-2.26-patched/ssh.pl      2008-09-09 15:54:59.125000000 +0200
@@ -15,5 +15,5 @@
 # Parse ssh-options
 while ($#ARGV>=0 && $ARGV[0] ne '--') {
-       push @SSHARGV, shift @ARGV;
+       push @SSHARGV, "\'" . shift(@ARGV) . "\'";
 }
 shift @ARGV if $ARGV[0] eq '--';

Remote Command Execution

  • SSH allows to execute any command on remote SSH host. The syntax is
% ssh -t SSH_HOST COMMAND
  • To execute a remote command on remote host and stay connected afterwards, use ssh -t, along with bash rcfile, like:
% ssh -t SSH_HOST "bash --rcfile PATH_TO_RC_FILE"

Don't miss the quotes around the command. Bash will execute the commands in the rc file, and will open a session. Connection remains open because stdin/stdout is not closed. Option -t allows for connecting with current terminal. Without this option, there will be no terminal connection, so bash would run in batch mode (no prompt), and terminal features like tab completion or color would be missing.

  • Another solution is to force bash interactive mode:
 % ssh SSH_HOST "bash --rcfile PATH_TO_RC_FILE -i"

Since there is no terminal, bash goes by default in non-interactive mode. Interactive mode is forced with option -i, and so prompt will be printed, etc. But this is only a partial solution because there is still no terminal, ie. no color, no TAB auto-completion.

Troubleshooting

  • ~/bin/ssh.pl from ssh-tunnel package currently interferes with the command. This is due to double argument processing and expansion. See patch above on v2.26.

SSH Config

SSH can be configured through file ~/.ssh/config. See man ssh_config for more information. The format is as follows:

# Specific configuration options for host host1
Host host1
  Option1     parameter
  Option2     parameter

# General configuration options for all hosts. 
# Options in this section applies if same option was *not already specified* in a relevant host section above.
Host *
  Option1     parameter
  Option2     parameter

The value to use for each option is given by the first section that matches the host specification and that provides a value for that option. So section Host * should always be at the end of the file, since any subsequent section will be ignored.

ProxyCommand

Specify the proxy command used by ssh to deal with proxies. If a default command is specified in host *, it can be overridden in a specific host section (use ProxyCommand none to tell ssh that there is no proxies).

Host myhost
  ProxyCommand    none
Host *
  ProxyCommand    /usr/local/bin/ssh-tunnel.pl -f - - %h %p