{"componentChunkName":"component---node-modules-gatsby-theme-document-src-templates-docs-js","path":"/openssh","result":{"data":{"mdx":{"body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"OpenSSH\",\n  \"description\": \"OpenSSH installation and basic and advance usage\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"OpenSSH is an open source suite for SSH, a cryptographic network protocol\\nfor operating network services securely over an unsecured network. \"), mdx(\"p\", null, \"OpenSSH can install a client and also a server. \"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"To check if you have the client installed, issue this command: \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"which ssh\")), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"To check if you have the server installed, issue this command: \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"which sshd\"))), mdx(\"h3\", {\n    \"id\": \"installation\"\n  }, \"Installation\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Client: \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"sudo apt install openssh-client\")), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Server: \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"sudo apt install openssh-server\"))), mdx(\"h3\", {\n    \"id\": \"basic-usage\"\n  }, \"Basic usage\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Connect to remote machine:\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"$ ssh user@remote_machine_ip\")), mdx(\"p\", null, \"Upon issuing the above command, you will need to authenticate to the remote server. There are two methods for authentication:\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"User and password of remote user (you need to enter user and password everytime you ssh)\"), mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Public and private keys (you don't need to enter user and password)\")), mdx(\"p\", null, \"The first time you connect to a remote server, you will have to authenticate with user and password. You then can generate a public and private key pair to authenticate. \"), mdx(\"h3\", {\n    \"id\": \"public-and-private-keys\"\n  }, \"Public and private keys\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Generate a public and private key:\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"$ ssh-keygen\")), mdx(\"p\", null, \"By default it will generate the file \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"~/.ssh/id_rsa\"), \", but you can edit the name.\"), mdx(\"p\", null, \"You can also select to generate a passphrase for the private key, which you will need to enter everytime you ssh. However, if you want to avoid entering the passphrase, you can add the private key to the \", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"ssh-agent\"), \", and you will only need to enter the passphrase once:\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"$ ssh-add ~/.ssh/id_rsa\")), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Copy the Public Key to remote machine(example: id_rsa.pub):\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"$ ssh-copy-id -i id_rsa.pub user@remote_machine_ip\")), mdx(\"p\", null, \"Alternatively, you can copy the Public key using these command:\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"cat ~/.ssh/id_rsa.pub | ssh user@remote_machine_ip \\\"mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >>  ~/.ssh/authorized_keys\\\"\")), mdx(\"h3\", {\n    \"id\": \"copying-files\"\n  }, \"Copying files\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"How to copy a file from local to remote (from local shell):\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"scp file_name user@remote_machine_ip:/home/remoteuser/\")), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"How to copy a file from remote to local (from local shell):\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"scp user@remote_machine_ip:file_name /home/localuser/\")), mdx(\"h3\", {\n    \"id\": \"connection-error-when-using-public-and-private-keys\"\n  }, \"Connection error when using public and private keys\"), mdx(\"p\", null, \"If the remote machine you used to ssh has been deleted and a new system has been installed with the same user and IP address, you will get an error when trying to ssh again.\"), mdx(\"p\", null, \"To solve this issue, you must delete the RSA remote host key from the known_hosts file in your local machine:\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ssh-keygen -R 192.168.1.43 -f ~/.ssh/known_hosts\")), mdx(\"h4\", {\n    \"id\": \"how-to-connect-over-the-internet\"\n  }, \"How to connect over the internet\"), mdx(\"p\", null, \"If you want to ssh connect with a machine over the internet, these are\\nthe basic settings:\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"p\", {\n    parentName: \"li\"\n  }, \"Port \", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"22\"), \" must be open. If you have\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://help.ubuntu.com/community/UFW\"\n  }), \"ufw\"), \" running,\\nopen port 22: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"sudo ufw allow 22/tcp\"))), mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"p\", {\n    parentName: \"li\"\n  }, \"Obtain your IP address.\"))), mdx(\"p\", null, \"Type \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ip addr | grep inet\"), \" to get your ip address. If it starts with\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"192.168.\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"172.16.\"), \" up to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"172.31.\"), \", or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"10.\"), \", you have a local\\n(aka private) ip address. Otherwise it is public (eg 74.125.224.51).\\nIf it is public, you have it easy. Anyone can try and connect with a\\ncommand like \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ssh bob@74.125.224.51\"), \".\"), mdx(\"p\", null, \"If you are stuck with a local IP address, you need to configure your\\nrouter to forward port 22 to your computer. Then you can go to a site\\nlike \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://whatismyip.org/\"\n  }), \"http://whatismyip.org/\"), \" to get your\\npublic ip address, and anyone who has it can try and connect with a\\ncommand like \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ssh bob@74.125.224.51\"), \".\"), mdx(\"ol\", {\n    \"start\": 3\n  }, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Get a permanent IP address\")), mdx(\"p\", null, \"Sign up with \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://dyndns.com/\"\n  }), \"http://dyndns.com/\"), \" for their free\\nHost Services to link a dyndns name to your ip address. I'm assuming\\nhere that you have not bought a static ip address from your ISP.\"));\n}\n;\nMDXContent.isMDXComponent = true;","tableOfContents":{"items":[{"url":"#installation","title":"Installation"},{"url":"#basic-usage","title":"Basic usage"},{"url":"#public-and-private-keys","title":"Public and private keys"},{"url":"#copying-files","title":"Copying files"},{"url":"#connection-error-when-using-public-and-private-keys","title":"Connection error when using public and private keys","items":[{"url":"#how-to-connect-over-the-internet","title":"How to connect over the internet"}]}]},"frontmatter":{"title":"OpenSSH","description":"OpenSSH installation and basic and advance usage"}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"id":"f77bac41-49ce-5034-8294-4d4877832c77"}}}