Commands tagged ssh (182)


  • -2
    complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
    sammcj · 2011-06-01 23:21:06 2

  • -1
    while true; do date; ssh <YOUR HOST HERE> "echo" && echo "HOST UP" && break; sleep 60; done
    unixmonkey11685 · 2011-05-29 19:54:16 0
  • If you need to xdebug a remote php application, which is behind a firewall, and you have an ssh daemon running on that machine. you can redirect port 9000 on that machine over to your local machine from which you run your xdebug client (I am using phpStorm) So, run this command on your local machine and start your local xdebug client, to start debugging. more info: http://code.google.com/p/spectator/wiki/Installing


    2
    ssh -R 9000:localhost:9000 you@remote-php-web-server.com
    nadavkav · 2011-05-28 09:39:16 1

  • 12
    apt-get install `ssh root@host_you_want_to_clone "dpkg -l | grep ii" | awk '{print $2}'`
    TuxOtaku · 2011-05-10 13:33:51 3
  • Booting the VM headless via VBoxHeadless requires knowledge of the VM's network in order to connect. Using VBoxManage in this way and you can SSH to the VM without first looking up the current IP, which changes depending on how you have your VM configured. Show Sample Output


    9
    ssh vm-user@`VBoxManage guestproperty get "vm-name" "/VirtualBox/GuestInfo/Net/0/V4/IP" | awk '{ print $2 }'`
    lucasrangit · 2011-05-04 18:01:36 0
  • This uses ssh to transfer the contents of one Mac's clipboard to another's. This only works with plain text, sadly. Trying to transfer images will just clear out the remote machine's clipboard, and rich text will be converted to plain text. Using the "Remote Login" must be enabled on the remote machine (via System Preferences' Sharing panel) for this to work.


    1
    pbpaste | ssh user@hostname pbcopy
    DavidLudwig · 2011-04-24 16:30:48 1
  • This version compresses the data for transport.


    1
    ssh username@remotehost 'mysqldump -u <dbusername> -p<dbpassword> <dbname> tbl_name_1 tbl_name_2 tbl_name_3 | gzip -c -' | gzip -dc - | mysql -u <localusername> -p<localdbpassword> <localdbname>
    putnamhill · 2011-03-11 14:57:04 2
  • In the example above 3 tables are copied. You can change the number of tables. You should be able to come up with variants of the command by modifying the mysqldump part easily, to copy some part of remote mysql DB.


    1
    ssh username@remotehost 'mysqldump -u <dbusername> -p<dbpassword> <dbname> tbl_name_1 tbl_name_2 tbl_name_3' | mysql -u <localusername> -p<localdbpassword> <localdbname> < /dev/stdin
    tur_ki_sh · 2011-03-09 18:35:07 1
  • This may be listed already but this command is useful to untar a specific directory to a different server.


    0
    cat tarfile.tar.gz | ssh server.com " cd /tmp; tar xvzf - directory/i/want"
    alf · 2011-02-11 17:10:01 1
  • If you are stuck behind a firewall and want to synchronize time with another server but you do not want to port forward NTP (which uses UDP) then this command is handy. It gets the time from a server and sets the local time. It is not that accurate but I can live with a second or so drift. Show Sample Output


    1
    date +%Y%m%d%T -s "`ssh user@server 'date "+%Y%m%d %T"'`"
    unixmonkey16473 · 2011-01-11 10:33:32 0
  • Run local scripts on remote server. "-T Disable pseudo-tty allocation"


    5
    ssh -T user@server < script.sh
    dlebauer · 2011-01-10 20:09:55 1
  • This command 1. SSH into a machine 2. Tunnels VNC port to your local computer ("-L 5900:localhost:5900") 3. Runs a single use vnc server ("x11vnc -safer -localhost -nopw -once -display :0") 4. Goes into the background ("-f") 5. Runs VNC viewer on the local computer connecting to the remote machine via the newly created SSH tunnel ("vinagre localhost:5900")


    21
    ssh -f -L 5900:localhost:5900 your.ssh.server "x11vnc -safer -localhost -nopw -once -display :0"; vinagre localhost:5900
    johnquail · 2010-12-29 08:41:10 2
  • Will return the SSH server key information for each host you have in your ~/.ssh/known_hosts file, including key size, key fingerprint, key IP address or domain name, and key type. Show Sample Output


    11
    ssh-keygen -l -f ~/.ssh/known_hosts
    atoponce · 2010-12-05 04:03:07 1
  • This command will copy command's output into your local clipboard


    1
    command | ssh myHost xsel -i --display :0
    wincus · 2010-11-23 19:59:22 0
  • - port 8080 on localhost will be a SOCKSv5 proxy - at localhost:localport1 you will be connected to the external source server1:remoteport1 and at bind_address2:localport2 to server2:remoteport2 - you will be using only IPv4 and arcfour/blowfish-cbc, in order to speed up the tunnel - if you lose the connection, autossh will resume it at soon as possible - the tunnel is here a background process, wiithout any terminal window open


    4
    autossh -M 0 -p 22 -C4c arcfour,blowfish-cbc -NfD 8080 -2 -L localport1:server1:remoteport1 -L bind_address2:localport2:server2:remoteport2 user@sshserver
    dddddsadasdasd · 2010-11-13 23:49:09 0
  • When debugging an ssh connection either to optimize your settings ie compression, ciphers, or more commonly for debugging an issue connecting, this alias comes in real handy as it's not easy to remember the '-o LogLevel=DEBUG3' argument, which adds a boost of debugging info not available with -vvv alone. Especially useful are the FD info, and the setup negotiation to create a cleaner, faster connection. Show Sample Output


    3
    alias sshv='ssh -vvv -o LogLevel=DEBUG3'
    AskApache · 2010-10-30 11:23:52 0
  • When using tcpdump, specify -U option to prevent buffering.


    12
    ssh root@HOST tcpdump -U -s0 -w - 'not port 22' | wireshark -k -i -
    abb · 2010-10-28 09:02:39 0

  • 0
    ssh user@remoteserver "PGPASSWORD='passwd' pg_dump -U user bd_name | bzip2 -zv9" | bzcat | psql -U user bd_name
    chronos · 2010-09-24 20:25:42 1
  • This version transfers gzipped data which is unzipped as it arrives at the remote host.


    3
    ssh user@host 'gunzip - > file' < file.gz
    putnamhill · 2010-09-20 14:04:47 0
  • use this command via ssh on remote machine when you want play video remove --directory if you want select single file


    0
    lol=`zenity --file-selection --directory` && DISPLAY=:0.1 cvlc -f -I ncurses --play-and-stop "$lol"
    rusino · 2010-09-12 01:10:16 0
  • use this command via ssh on remote machine when you want play video stream or path to file


    0
    lol=`zenity --entry` && DISPLAY=:0.1 cvlc -f -I ncurses --play-and-exit "$lol"
    rusino · 2010-09-12 01:02:53 0
  • ~ is the ssh control character. If you type it after a newline, you can example force close the ssh session. , ~, then . If you want more info, type ~? when you are connecting using ssh. Very useful to kill of any hanging ssh sessions when nothing else works.


    22
    ~.
    xeor · 2010-09-04 15:13:10 3

  • 9
    mussh -h host1 host2 host3 -c uptime
    george_007 · 2010-08-29 03:04:51 2

  • 14
    echo "uptime" | tee >(ssh host1) >(ssh host2) >(ssh host3)
    gutoyr · 2010-08-20 16:22:57 2
  • The pee command is in the moreutils package.


    15
    echo "uptime" | pee "ssh host1" "ssh host2" "ssh host3"
    dooblem · 2010-08-20 11:42:40 0
  • ‹ First  < 3 4 5 6 7 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: