ssh

Technical Notes

These notes are my personal online notebook of useful commands and "how-to's". You are welcome to make use of them if you find them helpful. They obviously don't come with any warranty! Click on one of the category tags above for the notes in any category.

Creating an ssh tunnel for mysql


ssh -N -f -L 3307:localhost:3306 user@myxhost.com
ssh -L 3307:localhost:3306 user@myxhost.com

-f = go to background
-L = local port to remote port binding
-N = no remote command to be executed

test with either of the following:

mysql -P 3307 -u dbuser -h 127.0.0.1 -p
mysql -P 3307 -u dbuser --protocol=TCP -p

tunnel can be closed with ps -ef | grep ssh and then kill the pid

http://www.webmasterworld.com/forum40/1010.htm

http://support.suso.com/supki/SSH_Tutorial_for_Linux

for windows:

How to create a password-less ssh login

How to create a password-less ssh login
based on: http://arctic.org/~dean/rdiff-backup/unattended.html

#log in as the user
host=server.com
hostnick=server
luser=localusername
suser=serverusername
#
mkdir -p .ssh
ssh-keygen -t rsa -f .ssh/id_rsa_$hostnick #generate key
############# You will be prompted for a password, press enter for no pw
#
#create .ssh/config file:
echo "host $hostnick" >> .ssh/config
echo "    hostname $host" >> .ssh/config
echo "    user $suser" >> .ssh/config
echo "    identityfile /home/$luser/.ssh/id_rsa_$hostnick" >> .ssh/config

browsing through an ssh proxy

Set up the proxy:
ssh -ND 8989 user@myproxysite.com
(will prompt for password and appear to hang)
use ctrl-C to break connection

Go to firefox preferences/advanced/connection-settings
o Manual proxy
o SOCKS host: localhost port: 8989
o SOCKSv5
no proxy for: localhost, 127.0.0.1

Browse to site:http://www.itistimed.com to verify your location

fuse filesystem with SSH

[writeup] **Warning: Tag still open at end of document:  "pre"
\
  • install fuse on Ubuntu:
apt-get install sshfs smbfs
yum install kernel-devel
yum install --enablerepo=rpmforge fuse dkms dkms-fuse
  • make a directory and mount a remote file system on it
mkdir /music
sshfs -o allow_other root@sv.isnew.org:/backups/music /music
  • to unmount system
fusermount -u /music
  • to mount a samba/windows share:
sudo smbmount //sv/comm

SSH/SCP without a password

scp syntax


scp -P 1234 root@isnewer.org:/home/andrew/filename .

This is a useful link to putty configuration: http://dag.wieers.com/blog/improving-putty-settings-on-windows

Syndicate content