LoginSignup
0
0

SSH connection

Posted at

SSH connection

how to connect

ssh username@remote_host

You should replace "username" with your remote username.
Also, you should replace "remote_host" with your remote hostname.

After that, you only need to enter the password and success connection!

How to skip the entering password

you should do the following settings if you want to skip entering password.

  • First
ssh-keygen

When type this command, id_rsa(secret key) and id_rsa.pub(public key) are generated in ~/.ssh in local PC.

  • next
    register the public key in ~/.ssh/authorized_keys in remote PC.
    please enter the following command.
ssh-copy-id -i id_rsa.pub username@remote_host

You should replace "username" with your remote username.
Also, you should replace "username" and "remote_host" of your own.

You can copy the contents of your local ~/.ssh/id_rsa.pub and write it directly to ~/.ssh/authorized_keys on your host.

Two step SSH

You should copy ~/.ssh/id_rsa.pub into ~/.ssh/authorized_keys of first and second PC.

And make following config file in ~/.ssh

Host [name2]
        User username
        HostName remote_host2
        ProxyCommand ssh username@remote_host1 -W %h:%p

Host [name1]
        User username
        HostName remote_host1

You can set name1 and name2 freely and also replace the username and hostname of your own.

When you login into the remote PC, you will enter the following command

  ssh name2 

remoteSSH

By using this, you can open the remotePC's file in local PC's vscode.

You should only install the extension (remote-SSH) to your PC.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0