开发者

How to change shell in unix

I'm new to unix. I need to copy file over ssh. This is what I do

me@localhost ~ $ ssh you@remotehost

Then I established ssh so I get

you@remotehost ~ $

I'd like to use scp to copy files fro开发者_运维技巧m localhost to remotehost. Once I have ssh connection, how do I change to prompt back to me@localhost so that I can use the scp command? Is there a command for that?

Edit: The reason I need the ssh is because after I copied the file I have to execute it. Is there a way to remain in the ssh session and use scp to copy the file that I'm editing at localhost


You do not have to first create an SSH connection to use SCP. Simply use the scp command from your shell, and it will connect to the other server.


Most shells exit with exit. CtrlD may also work.


You can also:

scp /path/to/local-file you@remotehost:/remote/path


Try screen command.


You can use scp on either side. Here are two examples:

If you are on your local host:

scp myfile you@remotehost:

If you are on the remote host:

scp you@<localhost's hostname>:myfile .

Substitute your localhost's hostname for <localhost's hostname> in the second command. If you are behind a router, it will be easier to use the first one.

Both assume that myfile is in the home directory on localhost and is being sent to the home directory on remotehost.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜