parsed.org

Tips by tag: ssh

External SSH Access by xinu on Dec 13, 2005 10:23 AM

You need to get someone into an internal machine that doesn't have a public IP? Use an SSH tunnel. For this example, machine_a is your internal machine and machine_b is external:

$ ssh -R 9000:localhost:22 you@machine_b

Once you've logged in, you should be able to run this on machine_b:

$ ssh -p 9000 you@localhost
commandsnetworkshellsshtunnel
Open a Backgrounded SSH Tunnel by cygnus on May 06, 2006 12:10 AM

If you want to open an SSH tunnel in the background, use the -N and -f switches:

ssh -Nf -L2121:localhost:21 user@host
authenticationencryptionsecurityshellsshtunnel
Restricting SCP Bandwidth Usage by cygnus on Oct 17, 2005 04:28 PM

You can use the -l <kilobits_per_sec> option with scp (NOT ssh or sftp) to restrict the bandwidth used to transfer files:

$ scp -l 200 user@host:~/files .
bandwidthcommandsnetworkrate-limitingscpsftpshellssh
Rsync and SSH by xinu on Jun 19, 2008 05:55 PM

Copying a directory from one system to another is easy:

$ rsync -avz -e ssh directory/ user@systemB:directory/
rsyncssh
SSH Config by xinu on Dec 05, 2007 10:48 AM

If you find yourself having to log into various systems with long strange names and usernames that aren't your own, check into ~/.ssh/config. Adding a Host block for each system you need to log into will give you a short name to use as well as let you set the user (and various other things - check out man ssh_config):

Host cs
  HostName cs.really.long.name.example.com
  User mrxinu

At this point you can type ssh cs and log right in.

commandsconfigurationsshssh_config
Tar + SSH by xinu on Feb 10, 2005 05:39 PM

To transfer files via tar/ssh, do the following:

$ tar cvjf - * | ssh user@remote "(cd /desired/path; tar xjf -)"
commandspipeshellsshtartunnel
Xargs & SSH by xinu on Apr 19, 2006 05:48 AM

Let's say you want to check the uptime on a list of servers. We're assuming that you've got a key on each machine otherwise you'll be entering your password often:

$ xargs -i ssh {} uptime < ./server.list
  5:46am  up 155 days, 17:49,  2 users,  load average: 0.12, 0.03, 0.01
  5:46am  up 147 days, 17:14,  2 users,  load average: 0.02, 0.05, 0.01
  5:46am  up 209 days, 17:26,  0 users,  load average: 0.00, 0.00, 0.00
  5:46am  up 89 days,  6:30,  0 users,  load average: 0.00, 0.00, 0.00
  5:46am  up 82 days,  6:40,  0 users,  load average: 0.07, 0.06, 0.01
  5:46am  up 104 days,  9:51,  0 users,  load average: 0.03, 0.03, 0.00
  5:50am  up 68 days,  9:17,  0 users,  load average: 0.00, 0.00, 0.00
  5:48am  up 68 days,  9:15,  0 users,  load average: 0.00, 0.00, 0.00
commandskeyloopremoteserversshellsshuptimexargs
RSS