Correct syntax for using SSH and SFTP on Ubuntu on irregular ports

I’m posting the following more for my own benefit and reference than anything else…

Correct syntax for SSH and SFTP on Ubuntu on irregular ports: (replace items in < > with your stuff, without the < >)

SSH:
ssh -p <port number> <username>@<server name>

SSH to accept socks 5 proxy on port you specify:
ssh -p <port number> <username>@<server name> -D <port to watch>

SFTP:
sftp -oPort=<port number> <username>@<server name>

Forward the X server from your remote box:
ssh -X -p <port number> <username>@<remote computer>

Unless your are a Linux geek or have some remote Linux servers you will probably never use this, but in case you do it sure is handy…

Next week we will dive into how to create a SSH tunnel (shunnel) using your Ubuntu box at home.


Technorati : , , , , , , , , , , , , , ,

About these ads

4 responses to “Correct syntax for using SSH and SFTP on Ubuntu on irregular ports

  1. This is helpful, and the reason I post HOWTOs on my site, to help me remember!

    Also, I use scp constantly to move things from work to my home server, but switches are different than those in ssh *and* cp! Ah, the inconsistent ways of *nix. So, following your above sftp example

    scp (put):

    scp -P -r @:

    scp (get):

    scp -P -r @:

    Pretty self explaniotry, but the -r is for recursive, just like cp’s -R.

  2. Ah, that didn’t work, the brackets were stripped. Ok, how about {}’s

    scp (put):
    scp -P {port} -r {files_or_directory} {username}@{servername}:{target_directory}

    scp (get):
    scp -P {port} -r {username}@{servername}:{files_or_directory} {target_directory}

  3. scp (and sftp) is fine for one or two files, but you might want to look at rsync for lots-o-files and/or directories. I’ll leave reading “man rsync” to the user, but to use rsync with remote irregular ports, you might do something like this:

    rsync (put):

    rsync -avuzb –rsh “ssh -p{port}” {/path/to/local/files_dirs} {user}@{host}:{/path/to/remote}

    rsync(get):

    rsync -avuzb –rsh “ssh -p{port}” {user}@{host}:{/path/to/remote} {/path/to/local}

  4. Thanks, dude. That helped me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s