Posts Tagged 'ssh'

Problems connecting to old Cisco routers with SSH?

It seems like something has changed in SSH, so that if you’re using a newer version (for example, you’ve just upgraded to Ubuntu 14.04) you may find you can no longer connect to your Cisco device – it just keeps saying “Connection closed”.

After some research, I found a solution for this. It’s probably only going to benefit a tiny number of people, but if you need it, here it is!

My first attempt involved a command-line like this:-

ssh -o HostKeyAlgorithms=ssh-rsa,ssh-dss -o KexAlgorithms=diffie-hellman-group1-sha1 -o Ciphers=aes128-cbc,3des-cbc -o MACs=hmac-md5,hmac-sha1 admin@myrouter

This definitely works, but I wanted to avoid having to type this each time. You can avoid this by adding an entry in $HOME/.ssh/config  like this:-

Host myrouter
    MACs hmac-md5,hmac-sha1
    Ciphers aes128-cbc,3des-cbc
    HostKeyAlgorithms ssh-rsa,ssh-dss
    KexAlgorithms diffie-hellman-group1-sha1
    User admin

Now I can just type “ssh myrouter” and it connects without an issue.


Copy and paste across machines with ssh + xsel

This is pretty obvious with hindsight but I only just thought of it!
I often have my work laptop on the desk next to my home desktop, and sometimes for whatever reason I need to copy & paste a URL or similar snippet between the machines.

Firstly, if you’ve never used xsel before, it’s very useful. Pipe something into it, and it becomes the current selection. Use it without input and it outputs the current selection buffer. It has a few more options, so check the man page.


grep foo ~/bar | xsel
xsel < ~/.conkyrc
xsel > ~/saved

Secondly, I strongly recommend that you set up public key authentication and ssh-agent if you haven’t already. It will make your life much easier!

Now the important part. To transfer the paste buffer from the current machine to a remote machine:

xsel | ssh -X "DISPLAY=:0.0 xsel -i"

Obviously you can replace the input with a local file or the output of a command just as easily, e.g:

ssh -X "DISPLAY=:0.0 xsel -i" < foo.html

In case you aren’t familiar with the traditional X11 paste method, this means you select something on the source machine, run the command above, and then use the middle mouse button on the remote machine to paste. If you don’t have one, use the left and right buttons simultaneously.

Hope this is useful!