Chinaunix首页 | 论坛 | 博客
  • 博客访问: 150290
  • 博文数量: 52
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 490
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-05 12:05
文章分类

全部博文(52)

文章存档

2013年(1)

2010年(3)

2009年(6)

2008年(25)

2007年(17)

我的朋友

分类:

2008-04-17 16:12:38

This document describes how to replace traditional remote access service rsh by ssh on various platforms.

 

is a free version of the SSH suite of network connectivity tools that increasing numbers of people on the Internet are coming to rely on. telnet, rlogin, ftp, and

the traditional remote access services

The following tasks are discussed:

 

·         How to use ssh to replace telnet, rsh and rlogin.

·         How to use scp to replace rcp.

·         How to use sftp to replace ftp for file transfer.

·         How to access server by ssh on Windows.

·         How to transfer file by sftp on Windows.

 

To access a server from on *nix machine, you can use ssh directly.  The usage is:

 

ssh hostname

 

To access the server as special account, you can also use:

 

ssh user@hostname

 

or

 

ssh hostname -l user

 

For example:

 

[root@node1 tmp]# ssh allenzhang@node2

allenzhang@node2's password:

Last login: Tue May 23 01:05:08 2006 from node1

[allenzhang@node2 ~]$

 

[root@node1 tmp]# ssh node2 -l allenzhang

allenzhang@node2's password:

[allenzhang@node2 ~]$

 

 

The usage of scp is much like rcp, and it can make more perfect. The -p option and -r option play the same roles as rcp as scp.  You can set the ownership of remote server.

 

     -p      Preserves modification times, access times, and modes from the original file.

     -r      Recursively copy entire directories.

 

To use scp:

 

scp source_file hostname:destination folder/file_name

 

For example:

 

[root@node1 tmp]# scp ic_env.pbd allenzhang@node2:/home/allenzhang

allenzhang@node2's password:

ic_env.pbd                                                          100%    0     0.0KB/s   00:00

[root@node1 allenzhang]# ls -l ic_env.pbd

-rw-r--r--  1 allenzhang allenzhang 0 May 23 01:09 ic_env.pbd

    There is another useful option in scp to set the used bandwidth

     -l limit Limits the used bandwidth, specified in Kbit/s.

 

 

sftp is much like ftp.  Commands of ftp are supported in sftp. You need not to set transfer mode to binary or ACSII in sftp.  In sftp or scp all transfers are all in binary.

 

For example:

 

[root@node1 tmp]# sftp allenzhang@node2

Connecting to node2...

allenzhang@node2's password:

sftp> help

Available commands:

cd path                       Change remote directory to 'path'

lcd path                      Change local directory to 'path'

chgrp grp path                Change group of file 'path' to 'grp'

chmod mode path               Change permissions of file 'path' to 'mode'

chown own path                Change owner of file 'path' to 'own'

help                          Display this help text

get remote-path [local-path]  Download file

lls [ls-options [path]]       Display local directory listing

ln oldpath newpath            Symlink remote file

lmkdir path                   Create local directory

lpwd                          Print local working directory

ls [path]                     Display remote directory listing

lumask umask                  Set local umask to 'umask'

mkdir path                    Create remote directory

progress                      Toggle display of progress meter

put local-path [remote-path]  Upload file

pwd                           Display remote working directory

exit                          Quit sftp

quit                          Quit sftp

rename oldpath newpath        Rename remote file

rmdir path                    Remove remote directory

rm path                       Delete remote file

symlink oldpath newpath       Symlink remote file

version                       Show SFTP version

!command                      Execute 'command' in local shell

!                             Escape to local shell

?                             Synonym for help

 

 

There are lots of free ssh client software on Windows platform. There are two recommendations: putty and SSH TectiaTM Client.

 

putty is free ssh client, it is green software as well. You can download it to your PC and use it directly. You can save the server configuration in putty and you need not input the IP address of server everytime.  After double-clicking the putty executable icon, it should show as below.

 

 

Double click the saved record, unix_server in this case, then you will connect to server directly.

 

 

You can get download the pscp.exe and psftp.exe to enable scp and sftp functions on your PC. you can save your putty tools to a special folder then set it as part of PATH in your environment.  Then you can use them everywhere on your pc.

 

 

set PATH=C:\path\to\putty\directory;%PATH%

 

D:\software>pscp.exe

PuTTY Secure Copy client

Development snapshot 2006-05-22:r6714

Usage: pscp [options] [user@]host:source target

       pscp [options] source [source...] [user@]host:target

       pscp [options] -ls [user@]host:filespec

Options:

  -V        print version information and exit

  -pgpfp    print PGP key fingerprints and exit

  -p        preserve file attributes

  -q        quiet, don't show statistics

  -r        copy directories recursively

  -v        show verbose messages

  -load sessname  Load settings from saved session

  -P port   connect to specified port

  -l user   connect with specified username

  -pw passw login with specified password

  -1 -2     force use of particular SSH protocol version

  -4 -6     force use of IPv4 or IPv6

  -C        enable compression

  -i key    private key file for authentication

  -noagent  disable use of Pageant

  -agent    enable use of Pageant

  -batch    disable all interactive prompts

  -unsafe   allow server-side wildcards (DANGEROUS)

  -sftp     force use of SFTP protocol

  -scp      force use of SCP protocol

D:\software>psftp.exe

psftp: no hostname specified; use "open host.name" to connect

psftp> help

!      run a local command

bye    finish your SFTP session

cd     change your remote working directory

chmod  change file permissions and modes

close  finish your SFTP session but do not quit PSFTP

del    delete files on the remote server

dir    list remote files

exit   finish your SFTP session

get    download a file from the server to your local machine

help   give help

lcd    change local working directory

lpwd   print local working directory

ls     list remote files

mget   download multiple files at once

mkdir  create directories on the remote server

mput   upload multiple files at once

mv     move or rename file(s) on the remote server

open   connect to a host

put    upload a file from your local machine to the server

pwd    print your remote working directory

quit   finish your SFTP session

reget  continue downloading files

ren    move or rename file(s) on the remote server

reput  continue uploading files

rm     delete files on the remote server

rmdir  remove directories on the remote server

 

 

You can get the latest putty from the URL below:

 

 

SSH TectiaTM Client

SSH TectiaTM Client is a ssh client that support both CLI and GUI for users, we can use ssh, scp and sftp after installation. We can download the NON-COMMERCIAL version on the following URL:

 

http://www.ssh.com/support/downloads/secureshellwks/non-commercial.html

 

After installing SSH TectiaTM Client, when CLI and GUI ssh client are both available. The path of ssh secure shell will be set to PATH of system automatically.

 

Z:\>echo %PATH%

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\SSH Communications Security\SSH Secure Shell

 


阅读(1649) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~