2016年11月13日

How to use SSH and SCP

I heard from Lab. member. He said that I don't know how to use SSH and SCP in command line.
Therefore I would like to explain how to use SSH and SCP.

SSH is achieve "secure connection" on the internet.
For example, you can connect linux server using such as TeraTerm.
Probably you are already using ssh!!

For instance, if you want to connect another server using ssh, you should type as the following,
$ ssh username@server.name
if your username is hogehoge, and server.name is example.com, you can login using folowing command
$ ssh hogehoge@example.com
Then we can use public key cryptography, example.com ask you passphrase in order to login.
Another we could not register public key to example.com, we can login using the our password.

We can create public key and private key pair easily following command.
$ ssh-keygen
After type this command, you should decide and type the passphrase.
You must choose your passphrase cafelly. this phrase must be long.
Long phrase is better than short it.
We can choose combination of favorite words, name, and so on.
Then, in order to carry out the passhrase authentication, we should put public key(*.pub) on the ~/.ssh directory of examle.com's your account, also your ~/.ssh directory must have authorized_keys file which contains your public key information.
Then we should copy public key safely. First choice is we copy the public key from your machine to example.com not using network, for example copy the public key via USB memory etc..
As another issue, we can use the scp command described as following,
$ scp ~/.ssh/id_rsa.pub hogehoge@example.com:./.ssh/id_rsa.pub
In this time, in order to achieve authentication, we type the your example.com's login password.
Scp command is similar to cp command.
$ scp local-file-name username@server.name:remote-file-name

After copy the public key, we should login one time to register from public key to authorized_keys
$ ssh hoge@example.com
$ cd .ssh
$ cat < id_rsa.pub >> authorized_keys
$ chmod 600 authorized_keys
$ logout

at this time you can use passphrase authentication.

Try it!!
posted by evakichi at 23:39| Comment(0) | Programming practice in English
この記事へのコメント
コメントを書く
お名前:

メールアドレス:

ホームページアドレス:

コメント:

認証コード: [必須入力]


※画像の中の文字を半角で入力してください。